Saturday, November 7, 2009

Find Factorial | C Programming

//wap to find factorial of any given no
#include
#include
void main()
{
int f=1, n, i;
clrscr();
printf(“\n\n enter a number: “);
scanf(“%d”,&n);
for(i=n;i>1;i--) //or use for(i=1; i<=n; i++)
{
f=f*i;
}
printf(“\n\n\a\tThe Factorial is :%d”,f);
getch();
}

o/p→
enter a number :





No comments:

Post a Comment