Thursday, 27 October 2011

C program to find factorial value

WRITE A C PROGRAM TO CALCULATE THE FACTORIAL VALUE OF A NUMBER





#include<stdio.h>
#include<conio.h>
void main()
{
 int n,i,t,f=1;
 printf("Enter the number:");
 scanf("%d",&n);
 for(i=n;i>=1;i--)
 {
  t=i;
  f=f*t;
 }
 printf("The factorial of the number is: %d",f);
 getch();
}


Output:
   Enter the number:5
   The factorial of the number is: 120

No comments:

Post a Comment