C Program to Find Factorial of a Number Using Function

In this program, you will learn how to find factorial of a number. The factorial of a number is the product of all the integers from 1 to that number. For example, the factorial of 4 (denoted as 4!) is 1*2*3*4 = 24. Factorial is not defined for negative numbers and the factorial of zero is one, 0! = 1 .

Source Code
#include <stdio.h>
int fact(int);
void main()
    int no, f;
    printf("Enter the number: ");
    scanf("%d", &no);
    f = fact(no);
    printf("Factorial = %d", f);
int fact(int n)
    int fc=1;
    while(n > 0)
        fc = fc * n;
    return fc;
Enter the number: 4
Factorial = 24

"Coding Hub - Learn to code" app now available on Google Play Store