ProgrammingHardTCS NQT · Wipro

What is printed? Assume unsigned short is 16 bits.

What is printed? Assume unsigned short is 16 bits.
#include <stdio.h>
int main(void) {
    unsigned short y = 60000;
    y += 10000;
    printf("%d", y);
}
  1. A. 4464
  2. B. 70000
  3. C. 5536
  4. D. 3536

Correct answer: A. 4464

60000 + 10000 = 70000, and 70000 - 65536 = 4464 is the value kept in a 16-bit unsigned short. The result 3536 comes from taking 65536 - 62000 by mistake.

More C Programming questions

Exams that ask this topic