ProgrammingHardTCS NQT · Infosys · Accenture
What will be the output of the following pseudocode?
What will be the output of the following pseudocode?
Integer c = 0
for (i = 100; i > 1; i = i / 3)
c = c + 1
end for
Print c- A. 3
- B. 4
- C. 5
- D. 33
Correct answer: B. 4
i takes 100, 33, 11, 3 (all > 1) and then 1, which stops the loop: four iterations.
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? (All variables are integers.) Integer a = 9, b = 2 a = a b b = a / b a = a / b Print…
- What will be the output of the following pseudocode? Integer i, s = 0 for (i = 1; i <= 20; i = i + 3) s = s + i end for Print s
- What will be the output of the following pseudocode? Integer a = 5, b = 9 a = a ^ b b = a ^ b a = a ^ b Print a 10 + b
- What will be the output of the following pseudocode? Integer i, j, c = 0 for (i = 1; i <= 6; i = i + 1) for (j = 1; j <= 6; j = j + 1) if…
- What will be the output of the following pseudocode? Integer n = 100, c = 0 while (n > 0) n = n / 2 c = c + 1 end while Print c
- What will be the output of the following pseudocode? Integer a[5] = {3, 8, 2, 7, 5}, i, total = 0, s = 0 for (i = 0; i < 5; i = i + 1)…