New Tutorials:   KOTLIN    JAVASCRIPT    SASS/SCSS    PL/SQL  
See the Tutorial List

Program to print Factorial of a Number

Below is a program to find factorial of a number using for loop.

void main()
   int fact, i, n;
   fact = 1;
   printf("Enter the number\t");
   scanf("%d" , &n);
   for(i = 1; i <= n; i++)
       fact = fact*i;
   printf("Factorial of %d is %d", n , fact);

Enter the number 5 Factorial of 5 is 120