ProgrammingVery hardGATE CS · TCS NQT
What is printed? Assume int is 32 bits.
What is printed? Assume int is 32 bits.
#include <stdint.h>
#include <stdio.h>
int main(void) {
uint8_t b = (uint8_t)-200;
printf("%d", b);
}- A. 200
- B. 4294967096
- C. 56
- D. 312
Correct answer: C. 56
Converting -200 to uint8_t gives (-200) mod 256 = 56. The value 312 comes from adding 256 instead of reducing modulo 256 by the correct amount.
More C Programming questions
- What is printed? c #include <stdio.h> int main(void) { char s[] = "abcdef"; char p = s; int n = 0; while (p && p - s < 4) n += p++ - 'a'…
- What is printed? c #include <stdio.h> #include <stdlib.h> int cmp(const void a, const void b) { const int x = (int const )a; const int y =…
- What is printed? c #include <stdio.h> int main(void) { int m[3][3]; for (int i = 0; i < 3; i++) for (int j = 0; j < 3; j++) m[i][j] = i 3…
- How many times is disk 3 moved in this recursive Towers of Hanoi with 5 disks? Compute the program output. c #include <stdio.h> int cnt =…
- How many integers n with 1 <= n <= 64 satisfy both (n & (n - 1)) == 0 and (n & 0x55555555u) != 0? Compute with this program. c #include…
- What is printed? c #include <stdio.h> int main(void) { int a[5]; int p = a + 4, q = a + 1; printf("%ld", (long)(p - q) (long)sizeof p); }