Factor

A factor is an integer that can be divided evenly into another number or in other words factors of a number are numbers that multiply to form a product.

Logic

To print all the factors of a particular number we have to iterate through all the smaller numbers up to the given number. If the user given number is completely divisible by any number then it is a factor of that number.

Program

#include <stdio.h>

int main() {

    int i, num;

    // Take input from user
    printf("Enter any number : ");
    scanf("%d", &num);

    printf("\nAll factors of %d are : \n", num);
    
    for(i = 1; i <= num; i++) {

        if(num % i == 0) {
            printf("%d ", i);
        }
    }

    return 0;
}

Output

Enter any number : 50
All factors of 50 are :
1 2 5 10 25 50