ProgrammingModerateCognizant GenC Next · Accenture
What will be the output of the following pseudocode? (code(c) gives a letter's character code and char(k) the reverse; 'A'..'Z' have consecutive codes)
What will be the output of the following pseudocode? (code(c) gives a letter's character code and char(k) the reverse; 'A'..'Z' have consecutive codes)
String s = "CODE", r = ""
for (each i from 0 to 3)
r = r + char((code(s[i]) - code('A') + 3 * i) mod 26 + code('A'))
end for
Print r- A. FRGH
- B. CRJM
- C. FUMQ
- D. CRJN
Correct answer: D. CRJN
Letter i is shifted by 3i: C+0 = C, O+3 = R, D+6 = J, E+9 = N, so CRJN. Shifting every letter by 3 gives FRGH.
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, so / is integer division) Integer n = 987654321, c = 0…
- What will be the output of the following pseudocode? Integer a[6] = {1, 2, 4, 5, 7, 9} Integer i = 0, j = 5, c = 0 while (i < j) if (a[i]…
- What will be the output of the following pseudocode? Integer a[7] = {2, -1, 4, 3, -2, 5, 1} Integer s = a[0] + a[1] + a[2], best = s for…
- What will be the output of the following pseudocode? Integer a[3] = {-3, -1, -4} Integer cur = 0, best = 0 for (each i from 0 to 2) cur =…
- What will be the output of the following pseudocode? (All variables are integers, so / is integer division) Integer r = 1, b = 3, e = 13…
- What will be the output of the following pseudocode? Integer c[0..5] = {1, 0, 0, 0, 0, 0} for (each i from 1 to 5) for (each j from 1 to…