How to calculate the factorial of a number by using c language?

Let's start the program🏁

#include <stdio.h>

int main() {

int num = 5;

int factorial = 1;

for (int i = 1; i <= num; i++) {

factorial *= i;

}

printf("Factorial of %d is %d\n", num, factorial);

return 0;

}

This program calculates the factorial of the number 5 and prints the result, which is 120.