ProgrammingModerateTCS NQT · Wipro
What is printed?
What is printed?
#include <stdio.h>
int main(void) {
printf("%d", 1 << 30 >> 28);
}- A. 2
- B. 4
- C. 8
- D. 16
Correct answer: B. 4
Both shifts are applied left to right on int values that stay in range: 1 << 30 = 2^30, then >> 28 gives 4.
More C Programming questions
- What is printed? A sorted int array {1, 3, 5, 7} is searched with bsearch for the key 6. c #include <stdio.h> #include <stdlib.h> int…
- How many subsets of {1, 2, 3, 4, 5} sum to exactly 10? Compute with this program. c #include <stdio.h> int main(void) { int c = 0; for…
- What is printed? c #include <stdio.h> #include <stdlib.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> int main(void) { unsigned s = 0; for (unsigned b = 1; b; b <<= 1) s += 1; printf("%u", s); }
- What is printed? c #include <stdio.h> int main(void) { printf("%d", (3 & 1) == 1 ? 'y' : 'n'); }
- What is printed? c #include <stdio.h> int main(void) { printf("%d", (7 & 5) | (2 ^ 6) << 1); }