C Program to Calculate Factorial of a Number
Factorial of an integer is the product of the integer and all the integers below it; e.g. factorial five ( 5! ) is equal to (5*4*3*2*1) =120.
- //C Program to calculate factorial of a number
-
- #include<stdio.h>
-
- int main()
- {
- int n, i, fact=1;
- printf("Enter a number: ");
- scanf("%d", &n);
-
- for (i=1; i<=n; i++)
- {
- fact=fact*i;
- }
-
- printf("Factorial = %d", fact);
- return 0;
- }
Output
