Calculate Factors of a Number

Using this program , u can find the factors of a number...



#include<stdio.h>
#include<conio.h>

void main()
{
long int s,n,r,again;
do
{
printf("enter a number = ");
scanf("%ld",&n);
printf("1 , ");
for(s=2;s<=n;)
{
r=n%s;

if(r==0)
{
printf("%ld , ",s);
n=n/s;
s=2;
}
else
{
s++;
}
}

printf("\n\ndo you want to try this again ?\nif yes , press 1 ,and then press enter button.\nif no ,then you can quit this application.\n");
scanf("%ld",&again);
printf("\n\n\n");
}
while(again==1);

getch();
return;
}

Post a Comment

0 Comments