Pseudo-code · Question 19 · Easy

What will be the output of the following pseudocode?

Integer n, c
Set n = 1, c = 0
while (n < 100)
    n = n * 3
    c = c + 1
end while
Print c
  1. 5
  2. 3
  3. 4
  4. 6
Answer and explanation

Answer: A. 5

Explanation: n takes the values 3, 9, 27, 81 and 243. The loop runs 5 times and stops once n reaches 243.

Previous: What will be the output of the following pseudocode? · Next: What will be the output of the following pseudocode? (Note: / denotes integer…

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