Easy Tutorial
❮ C Function Signal C Examples Fibonacci Series ❯

C Language Example - Finding All Factors of an Integer

C Language Examples

If a*b=c (where a, b, and c are integers), then we call a and b factors of c.

Example

#include <stdio.h>

int main()
{
    int number, i;

    printf("Enter an integer: ");
    scanf("%d", &number);

    printf("Factors of %d are: ", number);
    for(i = 1; i <= number; ++i)
    {
        if (number % i == 0)
        {
            printf("%d ", i);
        }
    }

    return 0;
}

Running Result:

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

C Language Examples

❮ C Function Signal C Examples Fibonacci Series ❯