This program will print the factorial of any number entered by user when this program is executed.factorial is given by,If we want to find the factorial of 6 then it will be 6*5*4*3*2*1 and similarly for 7 it will be 7*6*5*4*3*2*1.This program does same.
OUTPUT:
OUTPUT:
Enter number: 5
factorial is 120
CODE:
#include<stdio.h>
#include<conio.h>
main()
{
int n,fact=1,a;
clrscr();
printf("Enter Number: ");
scanf("%d",&n);
for(a=1;a<=n;a++)
{
fact=fact*a;
}
printf("\nFactorial is %d",fact);
getch();
}
#include<conio.h>
main()
{
int n,fact=1,a;
clrscr();
printf("Enter Number: ");
scanf("%d",&n);
for(a=1;a<=n;a++)
{
fact=fact*a;
}
printf("\nFactorial is %d",fact);
getch();
}