Thursday, August 19, 2010

C Programming - calculate factorial of given number

#include<stdio.h>
#include<conio.h>
void main()
{
int num,fact=1,i;
clrscr();
printf("\n enter the number=");
scanf("\n %d",&num);
for(i=fact;i<=num;i++)
{
fact=fact*i;
}
printf("\n factoral number=%d",fact);
getch();
}

output:-enter the number=5
factorial number=120

No comments:

Post a Comment