0
#include<iostream> using namespace std; void f(int n) { if (n == 1 || n == 0) return; else { cout <
Anyone can please explain this? How the output is 14 times Hello? How many times f(n-1) execute & f(n-2)? Explain step by step please!
5 Respostas
+ 5
Inside the function you print 2 times hello. So each call of f(n) produces 2 hello's.
I think it is like that: r = return (when n = 1)
f(5)
/ \
f(4) f(3)
/ \ / \
f(3) f(2) f(2) r
/ \
f(2) r
7 calls of f(n) -> 14 prints of hello
+ 5
Please upload your code to the code playground and post a link here
https://www.sololearn.com/Discuss/1316935/welcome-to-sololearn-forum/
+ 3
Denise Roßberg
Thank you 💚👍
+ 2
Anna
Link posted