Home » Programming & Data Structure » Programming and data structure miscellaneous » Question

Programming and data structure miscellaneous

Programming & Data Structure

  1. Consider the following two functions.

    The output printed when funl (5) is called is
    1. 53423122233445
    2. 53423120112233
    3. 53423122132435
    4. 53423120213243
Correct Option: C

In the given program, when the function fun 1() is calling function fun 2 (), after printing value and after returning from fun 2 (), it prints the same value. In the function fun 2 () also the same thing happens so by looking options we can find the correct sequence of the output after executing fun1 (5), (n = 5), fun1 (n), print ⇒ 5.
fun2 (n – 2) ⇒ fun2 (3), Print ⇒ 3.
Similarly all steps execute then, we get the correct. Sequence is 5 3 4 2 3 1 2 2 1 3 2 4 3 5 Hence, option (c) is correct.



Your comments will be displayed only after manual approval.