Monday, 11 August 2014

C language program to find out the factorial of an integer by calling a function.

#include<stdio.h>
void main()
{
          long int n;
          long int fact(long int n);
          clrscr();
          printf(" Enter a number: ");
          scanf("%ld",&n);
          printf(" Factorial of %ld is %ld",n,fact(n));
          getch();
}
long int fact(long int i)
{
          int fct=1;
          for(;i>=1;i--)
          fct*=i;
          return fct;

}

No comments:

Post a Comment