ProgrammingEasyTCS NQT · Infosys · Accenture
What will be the output of the following pseudocode?
What will be the output of the following pseudocode?
Integer n = 4096, c = 0
while (n > 0)
n = n / 10
c = c + 1
end while
Print c- A. 3
- B. 5
- C. 1
- D. 4
Correct answer: D. 4
Integer division removes one digit per pass: 4096, 409, 40, 4, 0 - four passes.
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? Integer p = 29, q = 6 Print (p mod q) + (p / q)
- What will be the output of the following pseudocode? Integer n = 3140, r = 0 while (n > 0) r = r 10 + n mod 10 n = n / 10 end while Print r
- What will be the output of the following pseudocode? Integer c = 0 for (each i from 1 to 5) for (each j from 1 to 5) if ((i + j) mod 3 ==…
- 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
- What will be the output of the following pseudocode? Integer A[6] = {5, 1, 7, 3, 9, 2}, s = 0 for (each i from 0 to 5, step 2) s = s +…
- What will be the output of the following pseudocode? Integer a = 0, b = 1, c for (each i from 1 to 6) c = a + b a = b b = c end for Print a