Find the factorial of a number

12.Write a program to find the factorial of a number?
#include
#include
void main()
{
int n,f=1,i=i;
clrscr();
printf("enter the no.");
scanf("%d",&n);
while(i<=n)
{
f=f*i;
i++;
}
printf("%d",f);
getch();
}


Algorithum
1.start
2.read n
3.calculate f=f*i
4.print factorial
5.stop


Result
The program is sucessfully executed and desired output is obtained

Output
Enter 2
2

0 comments:

Post a Comment