Open In App

Capgemini | Pseudocode Questions | Question 14

Predict the output of the following pseudo-code if x = 3 and y = 5:

Integer solve(int x, int y)
if(x < 5)
  solve(x + 2, y)
end if
print y
End function solve()

(A)



5

(B)



3

(C)

6

(D)

4

Answer: (A)
Explanation:

Irrespective of how many times the recursive function is called the value of y remains 5

Quiz of this Question
Please comment below if you find anything wrong in the above post

Article Tags :
Uncategorized