Monday, January 4, 2010

Program to find factorial of a number.


#include
#include

void main()
{
int n,i,fact=1;
clrscr();
printf("Enter any no: ");
scanf("%d",&n);
for(i=n;i>=1;i--)
{
fact=fact*i;
}
printf("Factorial=%d",fact);
getch();
}

'
Output:
       Enter a no: 5
       Factorial=120
 

No comments:

Post a Comment