Factor C - C Program to Find Factors of a Number



 c program to find factors of a number

Learn C - C tutorial - c program to find factors of a number - C examples - C programs

C Program to Find Factors of a Number

  • The numbers that are completely divisible by the given number are called as factors of a given number.
  • Factor of any number is a whole number which exactly divides the number into a whole number without leaving any remainder.
  • For example: 2 is a factor of 6 because 2 divides 6 exactly leaving no remainder.

Sample Code

#include <stdio.h>
int main()
{
    int number=60, i;
    printf("Positive integer:60\n");
    printf("Factors of %d are: ", number);
    for(i=1; i<=number; ++i)
    {
        if (number%i == 0)
        {
            printf("%d ",i);
        }
    }
    return 0;
}

Output

Positive integer:60
Factors of 60 are: 1 2 3 4 5 6 10 12 15 20 30 60 


View More Quick Examples


Related Searches to Factor C - C Program to Find Factors of a Number