Program To Calculate Factorial of a Number using For Loop - C Program

Program To Calculate Factorial of a Number using For Loop

In mathematics,the factorial of a non-negative integer n, denoted by n!, is the product of all positive integers less than or equal to n. For example, 5 ! = 5 × 4 × 3 × 2 × 1 = 120.

#include <stdio.h>
int main()
{
    int num,n;
    int fn = 1;
    printf("Enter the Number :");
    scanf("%d",&num);
    
    for(n=num;n>=1;n--)
        fn = fn * n;
        
    printf("Factorial Number of %d is %d", num, fn);
    
    return 0;
}

Output - Program To Find Factorial of a Number

Enter the Number :5                                                                                                   
Factorial Number of 5 is 120   
Compile and Run Online