Thursday, 9 October 2014

#include<iostream.h>
#include<conio.h>
int main()
{
     unsigned long int fact(int);
     unsigned long int f;
     int x;
     cout<<"Enter a Number: ";
     cin>>x;
     f=fact(x);
     cout<<"Factorial of  "<<x<<"  is  "<<f;
     return 0;
}
unsigned long int fact(int a)
{
    unsigned long int factorial;
    if(a==1)
              return 1;
   else
              factorial=a*fact(a-1);
   return factorial;
}


No comments:

Post a Comment