ProgrammingHardGATE CS · TCS NQT
What is printed?
What is printed?
#include <stdio.h>
int main(void) {
unsigned x = 1u << 31;
x <<= 1;
printf("%u", x);
}- A. 2147483648
- B. 0
- C. 1
- D. 4294967295
Correct answer: B. 0
Shifting the top bit out of an unsigned int leaves 0, since the shift is reduced modulo 2^32.
More C Programming questions
- 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…
- What is printed? c #include <stdio.h> int main(void) { unsigned x = 7; int i = 0; while (x & 1u) { x >>= 1; i++; } printf("%d", i); }
- What is printed? Assume unsigned short is 16 bits. c #include <stdio.h> int main(void) { unsigned short a = 255, b = 255; unsigned c = a…