Write a program to find factors of a number in C

Many times, this (program to find factors of a number in C) program ask in many examinations like BCA, O Level and B.Tech. (CS). It is easy to develop.

Anyone can develop it if he/she knows loops and conditional statements.

So, Let’s get started…

Program to find factors of a number in C


void main()
int n,fcount=0;i;

printf("Enter any number to check all factors");

printf("Total factorial of %d\n",n);
printf("Total factorial =%d",fcount);


Enter any number to check all factors 16
Total factorial of 16

1    2    4    8    
Total factorial = 4

Other programs Code

Program Code Execution (PCE)

Above we completed a program to find factors of a number in C. Let’s understand step by step.

First, input any integer (in ‘n’ variable) value through a user. I already assign some variable (‘n’, ‘fcount’ and ‘i’).

Use any loop (either for, while or do-while). Here, I am using for loop. I initialized fcount=0 and i=0;

terminate ‘i’ variable when ‘i’ variable reached just half of ‘n’ number. I check ‘n’ number from 1 to n/2 one by one. And display those numbers which divide ‘n’ number completely.

Also using fcount variable, it is used to count total factorials of any number.

Hope that you understand a program to find factors of a number in C. Please ask your questions in below comment section.

Don’t forget to share in social media family and friends in WhatsApp.

You can read our travel blog. You can choose your next trip through the blog. You definitely love it. please visit https://travelthenature.com

Leave a Comment

Show Buttons
Hide Buttons