The following code shows how to Find All Factors of a Number in C.

/******************************************************************************

                C program to find all factors of a number
*******************************************************************************/

#include <stdio.h>

int main()
{
    int i, n;
    printf("Enter a number: ");
    scanf("%d", &n);
    printf("The factors of %d are...\n", n);
    printf("%d ", 1);
    for(i=2;i<=n/2;i++)
    {
        if(n%i==0)
            printf("%d ", i);
    }
    printf("%d ", n);
    return 0;
}

Output


Further Reading

50+ C Programming Interview Questions and Answers

C Program to Find Factorial of a Number