Write a program to calculate the factorial of a given number
Here is the c source code/program for: Write a program to calculate the factorial of a given number.
/* a programme to calculate the factorial of a entered number*/
#include <stdio.h>
#include <conio.h>
void main()
{
int a,i;
int fact=1;
printf(“Enter the number to calculate the factorial: “);
scanf(“%d”,&a);
for(i=1; i<=a; i++)
{
fact=fact*i;
}
printf(“The factorial of %d is %d”,a,fact);
getch();
}
Comments (1)