ProgrammingVery hardTCS NQT · Infosys
What is printed?
What is printed?
#include <stdio.h>
int main(void) {
printf("%d", (1 << 4) | 3 & 5);
}- A. 17
- B. 1
- C. 21
- D. 5
Correct answer: A. 17
& binds tighter than |, so 3 & 5 = 1, and shift binds tighter than |, so 16 | 1 = 17.
More C Programming questions
- What is printed? c #include <stdio.h> int main(void) { printf("%d", (int)(7 / 2 2.0)); }
- What is printed? c #include <stdio.h> int main(void) { int a = 2, b = 3; printf("%d", a ^ b == 1); }
- What is printed? c #include <stdio.h> int main(void) { printf("%d", !!(0x80) + !0 + !-1); }
- What is printed? c #include <stdio.h> int main(void) { printf("%d", 5 % -3); }
- What is printed? c #include <stdio.h> #include <string.h> int main(void) { printf("%d", strlen("hello") > 4 ? 1 : 0); }
- What is printed? Assume int is 4 bytes. c #include <stdio.h> int main(void) { printf("%d", (int)sizeof(char[3][4])); }