C Program Calculate Factorial Of Given Number :
//C Program Calculate Factorial Of Given Number
#include<stdio.h>
#include<conio.h>
void main()
{
int num,fact=1;
clrscr();
printf("\n\n Enter the Factorial number:= ");
scanf("%d",&num);
if(num==0||num==1)
{
printf("\n Factorial is: 1");
}
else
{
while(num>=1)
{
fact=fact*num;
num=num-1;
}
printf("\n Factorial is:- %d",fact);
}
getch();
}
OUTPUT#include<stdio.h>
#include<conio.h>
void main()
{
int num,fact=1;
clrscr();
printf("\n\n Enter the Factorial number:= ");
scanf("%d",&num);
if(num==0||num==1)
{
printf("\n Factorial is: 1");
}
else
{
while(num>=1)
{
fact=fact*num;
num=num-1;
}
printf("\n Factorial is:- %d",fact);
}
getch();
}
No comments:
Post a Comment