ProgrammingModerateWipro NLTH · Cognizant GenC
What will be the output of the following pseudocode?
What will be the output of the following pseudocode?
Integer x = 1, i
for (i = 1; i <= 5; i = i + 1)
x = (x * 3) mod 7
end for
Print x- A. 1
- B. 3
- C. 5
- D. 6
Correct answer: C. 5
x goes 3, 2, 6, 4, 5 (mod 7), so it ends at 5.
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 i, s = 0 for (i = 1; i <= 10; i = i + 1) if (i mod 3 == 0) continue end if if…
- What will be the output of the following pseudocode? Integer n = 4021, r = 0 while (n > 0) r = r 10 + (n mod 10) n = n / 10 end while…
- What will be the output of the following pseudocode? Procedure p(Integer a[], Integer x) a[0] = a[0] + x x = x + 100 a[1] = x return x end…
- What will be the output of the following pseudocode? Integer c = 0 Function inc() c = c + 1 return c end function if (inc() > 0 || inc() >…
- What will be the output of the following pseudocode? Integer i = 5, j j = (i++) + (++i) Print i, j (i++ gives the old value and then adds…
- What will be the output of the following pseudocode? Integer n = 1000, c = 0 while (n != 0) n = n & (n - 1) c = c + 1 end while Print c (&…