ProgrammingHardAccenture · Capgemini

What will be the output of the following pseudocode?

What will be the output of the following pseudocode?
Integer c = 0
Function inc()
    c = c + 1
    return c
end function
if (inc() > 0 || inc() > 5)
    c = c + 10
end if
Print c
(|| does not evaluate its right side when the left side is true.)
  1. A. 12
  2. B. 2
  3. C. 13
  4. D. 11

Correct answer: D. 11

inc() returns 1 > 0, so the right operand is skipped; c = 1 + 10 = 11.

More Pseudocode and Code Tracing questions

Exams that ask this topic