Recursion
Given int 8;
(1) Write a program to solve 8! Using recursion technique.
(2) Using RAM diagrams show how the parameters are passed in your code.
#include <iostream>
using namespace std;
int factorial(int n)
{
return n ? n * factorial(n-1) : 1;
}
int main()
{
cout << factorial(8);
return 0;
}
Comments
Leave a comment