ProgrammingHardWipro · Cognizant pattern
What is printed?
What is printed?
int x = 1, y = 2, z = 3;
int result = x < y < z;
printf("%d", result);- A. 0
- B. Compilation error
- C. 3
- D. 1
Correct answer: D. 1
Parses as `(x < y) < z` = `(1 < 2) < 3` = `1 < 3` = 1 (true) — again, not a mathematical chained comparison, just two independent < operations evaluated left to right.
More C Programming questions
- What is printed? c int a = 5; int b = a++ + ++a; printf("%d %d", a, b);
- What is printed? c int a = 0; int b = (a = 5) == 5; printf("%d %d", a, b);
- What is printed? c #define ISEVEN(x) ((x) % 2 == 0) #define ISODD(x) (!ISEVEN(x)) int main(void) { int n = 7; printf("%d %d", ISEVEN(n)…
- What is printed? c int x = 7; int result = x % 2 == 0 ? x / 2 : x 3 + 1; printf("%d", result);
- What is printed? c #define PRINT(x) printf(#x " = %dn", x) int main(void) { int count = 5; PRINT(count); }
- What is printed? c #define MULTILINE(x) do { x = x 2; x = x + 1; } while (0) int main(void) { int v = 5; MULTILINE(v); printf("%d", v); }