ProgrammingModerateTCS NQT · Infosys · Accenture

What will be the output of the following pseudocode?

What will be the output of the following pseudocode?
Integer a = 84, b = 36, t
while (b != 0)
    t = b
    b = a mod b
    a = t
end while
Print a
  1. A. 6
  2. B. 36
  3. C. 24
  4. D. 12

Correct answer: D. 12

(84,36) -> (36,12) -> (12,0): this is Euclid's algorithm and gives the HCF 12.

More Pseudocode and Code Tracing questions

Exams that ask this topic