Monday 12 August 2013

Lecture 144

                Lecture 144
//Procedures and Functions
//Code:
#include <iostream>
#include <conio.h>
using namespace std;
int fac(int);    // Prototype 
main ()
{
  int number = 0;
  // Getting the input from the user
  cout << " Please enter the number to calculate the factorial ";
  cin>> number;
  cout << "\n The factorial number is : "<<fac(number);
  getch();
  return 0;
}
int fac(int n)
{
   if(n==0) return 1;
   if(n>0)  return fac(n-1)*n;   

}
Output: