Feb 2, 2013

Factorial Program

/*Factorial Program*/

#include"stdio.h"
#include"conio.h"
#include"math.h"
void main()
{
clrscr();
int i,n,fact=1;
printf("Enter the value of n=");
scanf("%d",&n);
if(n<0)
{
printf("Negative numbers are not allowed");
}
else
if(n==0)
printf("Factorial of =%d%d",n,fact);
else
{
for(i=2;i<=n;i++);
fact=fact*i;
printf("Factorial of=%d%d",n,fact);
}
getch();
}

No comments:

Post a Comment

Thank you for visit this site. You will get many programming news from here and learn programming very easily.

Popular Posts