Answer to Question #196164 in C++ for hillary

Question #196164

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.



1
Expert's answer
2021-05-20T18:22:23-0400
#include <iostream>

using namespace std;

int factorial(int n) 
{
    return n ? n * factorial(n-1) : 1;
}

int main()
{
    cout << factorial(8);
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog