Pseudo-code · Question 9 · Medium

What will be the output of the following pseudocode?

Integer a, b, c
Set a = 8, b = 5, c = 2
if ((a + b) mod c == 1 && a > b)
    a = a - c
    b = b + c
end if
Print a * b
  1. 42
  2. 40
  3. 30
  4. 48
Answer and explanation

Answer: A. 42

Explanation: (8 + 5) mod 2 = 1 and 8 > 5, so both conditions hold. a becomes 8 - 2 = 6 and b becomes 5 + 2 = 7, so a × b = 42.

Previous: What will be the output of the following pseudocode? · Next: What will be the output of the following pseudocode? (Note: << and >> are…

Practise pseudo-code

Try a fresh set of pseudo-code questions with an explanation after every answer, free and without signing up: Pseudo-code practice. Or sit a full placement mock test.

More pseudo-code questions

More technical & programming practice

C Programming · Java · Python · Data Structures · Algorithms · Object-Oriented Programming · DBMS · SQL

LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge