ProgrammingHardTCS NQT · Wipro

What is printed?

What is printed?
#include <stdint.h>
#include <stdio.h>
int main(void) {
    int16_t a = 200, b = 200;
    int p = a * b;
    printf("%d %d", p, p > 32767);
}
  1. A. 40000 0
  2. B. 25536 1
  3. C. -25536 0
  4. D. 40000 1

Correct answer: D. 40000 1

The operands are promoted to int, so the product 40000 is exact and exceeds the int16_t range. The comparison p > 32767 is therefore 1.

More C Programming questions

Exams that ask this topic