Saturday, March 10, 2012

Write a program to find the factorial of a number using loop.

#include
#include
void main()
{
int a,b,fact=1;
clrscr();
printf("Enter number to find factorial");
scanf("%d",&b);
for(a=b;a>0;a--)
{
fact=fact*a;
}
printf("%d ",fact);
getch();
}

No comments:

Post a Comment

Sociable