In this example, you will learn to find all the factors of an integer entered by the user.
#include<stdio.h>
int main()
{
int num, count = 1;
printf("Enter a number\n");
scanf("%d", &num);
printf("Factors of %d are:\n", num);
while(count <= num)
{
if(num % count == 0)
{
printf("%d\n", count);
}
count++;
}
return 0;
}
Output :
Enter a number
55
Factors of 55 are:
1
5
11
55
Ask anything about this examples