Write a program which employs Recursion

Showing Answers 1 - 3 of 3 Answers

satish_sudi

  • Jun 25th, 2007
 

#include<iostream>

using namespace std;

int fact(int n){
 if (n == 0)
  return 1;
 n=n*fact(n-1);
 return n;
}


int main() {
 int n=5;
 cout << "Factorial of number " << n << " is : " << fact(n) << endl;
 return 0;
}

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions