-->

program to print/display all factors of number 'n'.

 //program to print/display all factors of  number 'n'.
#include<stdio.h>
include<conio.h>
void main()
{
   int number,factors,i;
   printf("enter any positive number\n");
  scanf("%d",&number);
  for(i=1;i<=number;i++)
    {
      if(number%i==0)
        {                printf("the factors are=%d ",i);
        }getch();
}
--------------------------------------------------------------------------------------------------------------------------------------
logics in mind:
->enter a number whose factors value you want to find
->we have to go for repetitive process from number 1 to entered number 'number' i.e we divide given number 'number by 1,2,3... and itself. This we can apply using loop as shown above.If we get zero as remainder while dividing then we display that.

No comments:

Post a Comment