ProgrammingHardTCS NQT · Infosys
What is printed?
What is printed?
#include <stdio.h>
int main(void) {
printf("%d", (7 & 5) | (2 ^ 6) << 1);
}- A. 12
- B. 9
- C. 15
- D. 13
Correct answer: D. 13
7 & 5 = 5, 2 ^ 6 = 4, and 4 << 1 = 8 is computed before the OR, because shifts bind tighter than |. So the result is 5 | 8 = 13.
More C Programming questions
- What is printed? c #include <stdio.h> int main(void) { printf("%d", 5 > 3 ? 2 > 1 ? 7 : 8 : 9); }
- What is printed? c #include <stdlib.h> #include <stdio.h> int cmp(const void a, const void b) { int x = (const int )a, y = (const int )b…
- What is printed? c #include <stdio.h> unsigned fib(unsigned n) { unsigned a = 0, b = 1; for (unsigned i = 0; i < n; i++) { unsigned t = a…
- What is printed? c #include <stdio.h> void rev(const char s) { if (s == '0') return; rev(s + 1); putchar(s); } int main(void) {…
- What is printed? c #include <stdio.h> int calls = 0; int A(int m, int n) { calls++; if (m == 0) return n + 1; if (n == 0) return A(m - 1…
- What is printed? c #include <stdio.h> int main(void) { unsigned x = 0x16D; printf("%u", x & 0xF); }