ProgrammingModerateTCS NQT · Infosys

What is printed?

What is printed?
#include <stdio.h>
int main(void) {
    printf("%d", (13 << 1) + 13);
}
  1. A. 38
  2. B. 40
  3. C. 36
  4. D. 39

Correct answer: D. 39

(x << 1) + x is the classic 3x trick: 13 << 1 = 26, plus 13 gives 39. 38 and 40 are slips around 3 x 13, and 36 treats the shift as adding 10.

More C Programming questions

Exams that ask this topic