google-site-verification: googlef8aa845b858144d3.html COMPUTER SCIENCE NOTES: FACTORIAL : (Example 1)

Monday, July 17, 2017

FACTORIAL : (Example 1)

/*find the factorial  of a number */
#include<stdio.h>
#include<conio.h>
void main()
{
int n,num;
long fact=1;
clrscr();
printf("Enter the number :");
scanf("%d",&n);
num=n;
if(n<0)
printf("No factorial of -ve number \n");
else
{
while(n>1)
{
fact*=n;
n--;
}
printf("factorial of %d =%ld",num,fact);
}
getch();
}

No comments:

Post a Comment