+ 6
Let's see what happen at every recursion step :- func(5) { 5>0 true so call func(4) first} func(4) { 4>0 true so call func(3) first} . . func(1) { 1>0 true so call func(0) first} func(0) { 0>0 false so skip the stuff in *if* statement and backtrack } back to func(1)'s cout statement which displays value of "x" that is decremented to 0 here. Again backtrack Display 1, as new value of "x" is 1 and again backtrack similarly display 2 and so on . . . Final output = 01234
21st Nov 2020, 12:04 PM
Arsenic
Arsenic - avatar