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:
- #include <stdio.h>
- int main()
- {
- //Variables declearation.
- int number, i;
- //Input a number.
- printf("Enter a positive integer: ");
- scanf("%d",&number);
- printf("\n Factors of %d are:\n ", number);
- //calculate the factors.
- for(i=1; i <= number; ++i)
- {
- if (number%i == 0)
- {
- //disply the numbers.
- printf("\t %d ",i);
- }
- }
- return 0;
- }
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    
 May 13, 2020
May 13, 2020

 
 
0 comments:
Post a Comment