ProgrammingModerateTCS NQT · Infosys pattern
What is printed?
What is printed?
printf("%d", 1 << 3 + 1);- A. 16
- B. 8
- C. 2
- D. 9
Correct answer: A. 16
Additive operators bind tighter than shift operators, so this is 1 << (3 + 1) = 1 << 4 = 16. Reading it as (1 << 3) + 1 gives the trap answer 9.
More C Programming questions
- On a typical compiler where int is 4 bytes and 4-byte aligned, what is printed? c struct S { char c; int i; char d; }; struct T { int i…
- With 4-byte int, consider int (p)[5]; Which is correct?
- int a[3][4]; is stored in row-major order starting at address 1000, with 4-byte int. What is the address of a[2][1]?
- What is printed? c unsigned char c = 250; c += 10; printf("%d", c);
- What does f(3) print? c void f(int n) { if (n > 0) { f(n - 1); printf("%d ", n); f(n - 1); } }
- What is printed? c char a[] = "hi", b[] = "hi"; if (a == b) printf("same"); else printf("different");