C Program to display Positive factors of a number


Write a program in C to display all the positive factors of a number enter by the user.

How to find and display positive factors of a number in C ?

Below is a program in C demonstrating how to do it.

#include <stdio.h>
int main()
    int inputNumber, index;
    printf("Abundantcode.com coding sample\n");
    printf("Enter a Number :");

    printf("Positive factors of the number %d are below: ", inputNumber);
    for(index=1; index <= inputNumber; ++index)
        if (inputNumber%index == 0)
            printf("%d ",index);
    return 0;


Abundantcode.com coding sample

Enter a Number :5

Positive factors of the number 5 are below: 1 5

Tags :

Leave Your Comment

Liked this content?. Please spread the word :)