Program to calculate the factorial of a given number
#include <stdio.h>
#include <conio.h>
void main()
{
int i;
int n;
int fact = 1;
clrscr();
printf("Enter the number: ");
scanf("%d",&n);
for( i = 1 ; i <= n ; i++ )
{
fact = fact*i;
}
printf("Factorial of %d is : %d",n,fact);
getch();
}
Output :

0 comments:
Post a Comment