ProgrammingVery hardCognizant GenC · C · Advanced
What is printed?
What is printed?
unsigned char a = 250, b = 10;
printf("%d %d", (a + b) > 255, (unsigned char)(a + b));- A. 0 4
- B. 1 260
- C. 1 4
- D. 0 260
Correct answer: C. 1 4
Both operands are promoted to int, so a + b is 260 and 260 > 255 is true; the cast to unsigned char wraps 260 to 4.
More C Programming questions
- What is printed? c uint8t x = 0xA5; x = (x << 4) | (x >> 4); printf("%d %d", x, (uint8t)~x);
- What is printed? c int add(int a, int b) { return a + b; } int sub(int a, int b) { return a - b; } int mul(int a, int b) { return a b; }…
- What is printed? c struct N { int v; struct N nx; }; int main(void) { struct N c = {3, 0}, b = {2, &c}, a = {1, &b}; struct N p = &a…
- What is printed? Assume C99 or later. c int g(int a, int b) { return b ? g(b, a % b) : a; } int main(void) { printf("%d %d", g(-48, 18)…
- What is printed? c #define MAX(a, b) ((a) > (b) ? (a) : (b)) int main(void) { int i = 3, j = 1; int m = MAX(i++, j++); printf("%d %d %d"…
- In C, sizeof(char) is: