C Program To Find Factorial of Number and check for negative Number

C Program To Find Factorial of Number and check for negative Number, Factorial Program in C, C Assignments to find factorial of number, factorial in C



#include
#include
void main()
{
int n,num;
clrscr();
long fact=1;
printf("\n Please enter the number");
scanf("%d",&n);
num=n;
if(n<0)
printf("no factorial of negative number");
else
{
while(n>1)
{
fact*=n;
n--;
}
printf("factorial of %d=%ld",num,fact) ;
}
getch();
}



No comments:

Post a Comment