Solved programming problem

How to Find the Factorial in C.

Source code

#include<stdio.h>

int main()

{

    int n,fact=1,i;

    printf("Please enter A Number : ");

    scanf("%d",&n);

    ///calculate the factorial

   for(i=1;i<=n;i++)

   {

       fact=fact*i;

   }

    printf("
 Factorial of %d is : %d
",n,fact);

    return 0;

}

Output

Please enter A Number :5

Factorial of 5 is 120

Join the discussion

Add your comment