ProgrammingHardTCS NQT · Wipro
What is printed?
What is printed?
#include <stdio.h>
int main(void) {
unsigned a[] = {5, 3};
printf("%u", a[0] - a[1] * 2);
}- A. 4294967294
- B. 1
- C. 4294967295
- D. 3
Correct answer: C. 4294967295
a[1] * 2 = 6, and 5 - 6 wraps modulo 2^32 to 4294967295. The signed value -1 is not what an unsigned expression produces.
More C Programming questions
- What is printed? c #include <stdio.h> int main(void) { int p = (int[]){1, 2, 3}; printf("%d", p[1] p[2]); }
- What is printed? c #include <stdio.h> int main(void) { printf("%u", 1u << 31 >> 30); }
- What is printed? c #include <stdio.h> int main(void) { char w[] = {"ab", "cd", "ef"}; char p = w + 2; printf("%c%c", (p)[0], p[-1][1]); }
- What is printed? c #include <stdio.h> int main(void) { unsigned v = 0x01020304u, total = 0; for (int i = 0; i < 4; i++) { unsigned b = (v…
- What is printed? Compute the XOR of all integers from 1 to 1000 with this program. c #include <stdio.h> int main(void) { unsigned x = 0…
- How many monotone lattice paths go from the top-left corner to the bottom-right corner of a 4 by 4 grid of cells (moves only right or…