Factors of a given number | C Program


Write a program to find the factors of a given number. [Dec 2014, Set-4]

#include <stdio.h>

int main()
{
    int i, n, sum = 0;
    
    printf("Enter an integer :");
    scanf("%d", &n);

    printf("The factors are :\n");
    for (i = 1; i <= n; i++)
    {
        if (n % i == 0)
            printf("%d ", i);
    }
    
    return 0;
}