C Program to Find Factorial of given number except negative number

C Program to Find Factorial of given number except negative number.

#include
#include
void main()
{
int n,num;
clrscr();
long fact=1;
printf("\n 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();
}


1 comment:

  1. i need c program that when we give input as 123450 we must get output as one lakh twentythree thousand four hundred fifty

    ReplyDelete