C Program to Display Factor of a Given Number

You can run this program by compiling it using a C compiler. When you run the program, it will prompt you to enter a number, and then it will display the factors of that number. Factors are the numbers that divide the given number without leaving a remainder.

Program :

#include <stdio.h>
#include<conio.h>
int main() {
int num, i;
printf(“Enter a positive integer: “);
scanf(“%d”, &num);
printf(“Factors of %d are: “, num);
for (i = 1; i <= num; ++i) {
if (num % i == 0) {
printf(“%d “, i);
}
}
return 0;
}

Output :

Leave a Comment

Your email address will not be published.

Shopping Basket
Verified by MonsterInsights