Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

C-program to find the factors of a number



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 number

CODE---->


#include
#include
color> void main()color>
{
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();
}



Don't just read, write it, run it.....color>

RESULT:color>






This post first appeared on ProgramJoy.blogspot.com, please read the originial post: here

Share the post

C-program to find the factors of a number

×

Subscribe to Programjoy.blogspot.com

Get updates delivered right to your inbox!

Thank you for your subscription

×