Consider the following two functions. void fun1 (int n) { if (n == 0) return; printf(“%d”, n); fun2(n – 2); printf (“%d”, n); } void fun2(int n) { if (n == 0) return; printf (“%d”, n); fun1(++n); printf(“%d”, n); } The output printed when fun1 (5) is called is
Consider the following two functions. void fun1 (int n) { if (n == 0) return; printf(“%d”, n); fun2(n – 2); printf (“%d”, n); } void fun2(int n) { if (n == 0) return; printf (“%d”, n); fun1(++n); printf(“%d”, n); } The output printed when fun1 (5) is called is Correct Answer 53423122233445
STEP:
This problem can be solved using tree approach. Make a tree as the function call arrives, then traverse the tree from top to bottom and left to right.
Diagram:
So, output printed when fun1(5) is called is 53423122233445.
মোঃ আরিফুল ইসলাম
Feb 20, 2025