ProgrammingModerateTCS NQT · Wipro
What will be the output of the following pseudocode?
What will be the output of the following pseudocode?
Function f(Integer a, Integer b)
return a * b - (a + b)
End Function
Print f(f(2, 3), f(1, 4))- A. -3
- B. -1
- C. 0
- D. 5
Correct answer: B. -1
Inner calls first: f(2, 3) = 6 − 5 = 1 and f(1, 4) = 4 − 5 = −1. Then f(1, −1) = (1)(−1) − (1 + (−1)) = −1 − 0 = −1.
Practise more Pseudocode and Code Tracing questionsPseudocode and Code Tracing: notes and key points
More Pseudocode and Code Tracing questions
- What will be the output of the following pseudocode? (Strings are indexed from 0) Integer calls = 0 Function pal(String s, Integer i…
- What will be the output of the following pseudocode? Integer s = 0, i = 0 while (i < 10) i = i + 1 if (i mod 3 == 0) continue end if s = s…
- What will be the output of the following pseudocode? (Arrays are indexed from 0) Integer a[5] = {10, 20, 30, 40, 50}, b[5], k = 2, n = 5…
- What will be the output of the following pseudocode? (Strings are indexed from 0) String s = "ABBCCCDDDD" Integer best = 0, run = 1 for…
- What will be the output of the following pseudocode? Integer M[2][2] = {{1, 1}, {1, 0}}, R[2][2] = {{1, 0}, {0, 1}}, T[2][2] for (each k…
- What will be the output of the following pseudocode? (All variables are integers, so / is integer division) Integer s = 0 for (each i from…