Subscribe Us

header ads

To find factorial of a given number



C Program to find Factorial of a given number

#include<stdio.h>
#include<math.h>
void main()
{
    int n,i,f=1;
    printf("\n enter the value of n 
    \n");
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        f=f*i;
    }
    printf("\n factorial = %d",f);
}

Output:-

 enter the value of n
5

 factorial = 120

Post a Comment

0 Comments