ProgrammingModerateTCS NQT · Infosys
What is printed?
What is printed?
#include <stdio.h>
int main(void) {
printf("%d", (13 << 1) + 13);
}- A. 38
- B. 40
- C. 36
- 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
- How many numbers from 1 to 100 are multiples of 16? Compute with this program. c #include <stdio.h> int main(void) { int c = 0; for…
- What is printed? c #include <stdio.h> int main(void) { unsigned x = 1u << 31; x <<= 1; printf("%u", x); }
- What is printed? c #include <stdio.h> int main(void) { printf("%d", 'n' == 10 && '0' == 0); }
- What is printed? Assume uint8t is 8 bits. c #include <stdint.h> #include <stdio.h> int main(void) { uint8t x = 0x1F; uint8t r =…
- What is printed? c #include <stdio.h> #include <stdlib.h> int ds(int n) { int s = 0; while (n) { s += n % 10; n /= 10; } return s; } int…
- How many ordered ways are there to write 6 as a sum of parts 1, 2 and 3? Compute with this program. c #include <stdio.h> int f(int n) { if…