Factors are the integers that are multiplied together to find the other integers.
as a example-If we say the number is  5 the it is multiplied by 1 and 5.
also it 10=1*2*5*10

Source Code:

  1. #include <stdio.h>
  2. int main()
  3. {
  4. //Variables declearation.
  5.     int number, i;

  6.     //Input a number.
  7.     printf("Enter a positive integer: ");
  8.     scanf("%d",&number);

  9.     printf("\n Factors of %d are:\n ", number);
  10.     
  11.     //calculate the factors.
  12.     for(i=1; i <= number; ++i)
  13.     {
  14.         if (number%i == 0)
  15.         {
  16.        
  17.         //disply the numbers.
  18.             printf("\t %d ",i);
  19.         }
  20.     }

  21.     return 0;
  22. }

Output:

        1. Enter a positive integer: 10
              Factors of 10 are:
                1       2       5       10

       2.  Enter a positive integer: 25                                                                                                                               Factors of 25 are:    
                  1       5       25    

0 comments:

Post a Comment