In this C-program we will find the factors of a number. The number will be taken from the user.color>
input:
The number(i.e : 5,6,9 etc.)output:
The factors of the given numberCODE---->
#include
#include
{
int n,i;
clrscr();
printf("Enter a number:color>");
scanf("%dcolor>",&n);
if(ncolor>)
{
printf("\n%d is a negative number. Factors of a negative number doesn't exist.color>",n);
}
if(n==0color>)
{
printf("\nThe factors of 0 is = 0color>");
}
if(n>0color>)
{
printf("\nThe factors of %d are:color>",n);
for(i=1color>;i;i++color>)
{
if(n%i==0color>)
printf("%d,color>",i);
}
}
getch();
}
color>