ProgrammingHardTCS Digital · Capgemini
What will be the output of the following pseudocode?
What will be the output of the following pseudocode?
// Integer16: 16-bit signed integers in two's complement; results wrap around Integer16 x = 30000 x = x + 30000 Print x
- A. 60000
- B. -32768
- C. 27232
- D. -5536
Correct answer: D. -5536
A 16-bit signed integer holds −32768 to 32767. 60000 exceeds that, so it wraps by 65536: 60000 − 65536 = −5536.
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? Record r[4] = {(3, 'a'), (1, 'b'), (3, 'c'), (1, 'd')} // (key, letter) for (each i…
- What will be the output of the following pseudocode? (Arrays are indexed from 0) Integer a[7] = {4, 2, 2, 8, 3, 3, 1}, cnt[0..8] = all 0…
- What will be the output of the following pseudocode? (Arrays are indexed from 0) Integer a[8] = {170, 45, 75, 90, 802, 24, 2, 66} List…
- What will be the output of the following pseudocode? (All variables are integers, so / is integer division) Integer lo = 1, hi = 1000…
- What will be the output of the following pseudocode? (^ is bitwise XOR) Integer x = 0 for (each i from 1 to 10) x = x ^ i end for Integer…
- What will be the output of the following pseudocode? (^ is XOR, & is AND, >> is right shift) Integer x = 21, z = 22 Integer y = x ^ (x >>…