Pages

Sunday, February 15, 2015

C program to calculate the factorial of an integer


#include<stdio.h>
#include<conio.h>

void main()
{
long i,n,fac=1;
clrscr(); //to clear the screen

printf("Enter value of n:");
scanf("%ld",&n);
for(i=n;i>=1;--i)
fac*=i;

printf("
Factorial of %ld is %ld",n,fac);

getch(); //to stop the screen
}

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.