ProgrammingModerateAccenture · Capgemini
What will be the output of the following pseudocode?
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
- A. 59
- B. 14
- C. 45
- D. 95
Correct answer: D. 95
The three XOR steps swap a and b, so a = 9 and b = 5, and a * 10 + b = 95.
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, 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)…
- What will be the output of the following pseudocode? String s = "education" Integer i, c = 0 for (i = 0; i < length(s); i = i + 1) if…
- What will be the output of the following pseudocode? Function f(Integer n) if (n <= 1) return 1 end if return f(n - 1) + f(n - 2) end…
- 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