Program to print Factorial of a Number - Coding is Funny

Program to print Factorial of a Number

Program to print Factorial of a Number

Below is a program to find factorial of a number using for loop.
#include<stdio.h>
#include<conio.h>
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);
   getch();
}

OUTPUT:

Enter the number 5 Factorial of 5 is 120

  • Share: