Factorial of a number in C

Source code :

#include<stdio.h>

int main(){
    
  int i,fact=1,num;
 
  num = 5; //Change the number here
 
  for(i=1;i<=num;i++)
      fact=fact*i;
 
  printf("Factorial of %d is: %d",num,fact);
  return 0;
}

Output :

Factorial of 5 is: 120

Output :


                

Comments :