ProgrammingVery hardTCS NQT · Infosys
What is printed? Assume int is 32 bits.
What is printed? Assume int is 32 bits.
#include <stdio.h>
int main(void) {
unsigned a = 10;
int b = -3;
printf("%u", a % b);
}- A. 7
- B. 4294967293
- C. 3
- D. 10
Correct answer: D. 10
In a % b the signed -3 becomes the unsigned value 4294967293, which is far larger than 10, so the remainder is 10 itself. A signed remainder would be 1.
More C Programming questions
- What is printed? c #include <stdio.h> int main(void) { unsigned x = 40; int c = 0; while (!(x & 1u)) { x >>= 1; c++; } printf("%d", c); }
- What is printed? c #include <stdio.h> int main(void) { int a[] = {1, 2, 2, 3, 1, 4}; int c = 0; for (int i = 0; i < 5; i++) if (a[i] < a[i…
- For uint32t a = 5 and b = 3, how many of these statements are true? (i) a - b > a (ii) (a - b) + b == a (iii) ~a == UINT32MAX (iv) a / b b…
- What is printed? c #include <stdio.h> int main(void) { int a[3][4]; for (int i = 0; i < 3; i++) for (int j = 0; j < 4; j++) a[i][j] = i 4…
- What is printed? Assume unsigned int is 32 bits. c #include <stdio.h> int main(void) { unsigned x = 0xABCD; printf("%u", (x >> 5) & 7u); }
- What is printed? c #include <ctype.h> #include <stdio.h> int main(void) { const char s = "Hello World"; int n = 0; for (const char p = s…