Thursday, 16 July 2020

Factorial Program in C

Factorial Program in C 

This code is very simple and easy to write Factorial Program in C

factorial program in c

#include<stdio.h>
#include<conio.h>
void main()
{
    int n,i,f;
    f=i=1;
    clrscr();
    printf("Enter a Number to Find Factorial: ");
    scanf("%d",&n);
    while(i<=n)
    {
        f*=i;
        i++;
    }
    printf("The Factorial of %d is : %d",n,f);
    getch();
}


Output


Enter a Number to Find Factorial: 5
The Factorial of 5 is : 120

No comments:

Post a Comment