ProgrammingModerateInfosys · C
What is printed?
What is printed?
#define SQ(x) x * x
printf("%d", SQ(2 + 1) + SQ(3));- A. 18
- B. 12
- C. 14
- D. 16
Correct answer: C. 14
SQ(2 + 1) expands to 2 + 1 * 2 + 1 = 5, not 9; SQ(3) = 9; the total is 14.
More C Programming questions
- What is printed? c int a = 3, b = 4; printf("%d", a < b ? a > 1 ? 10 : 20 : 30);
- What is printed? Assume a 4-byte int. c int m[3][4]; printf("%zu %zu %zu", sizeof(m[0]), sizeof(m), sizeof m);
- What is printed? c int a[2][3] = {{1, 2, 3}, {4, 5, 6}}; int p = &a[0][0]; printf("%d %d %d", (p + 4), (a[1] + 2), (a)[2]);
- What is printed? c int i, j; for (i = 0, j = 5; i < j; i++, j--) ; printf("%d %d", i, j);
- What is printed? c int a = 0, b = 0, c; c = (a++ && b++) || (++a || b++); printf("%d %d %d", a, b, c);
- What is printed? c int a = -1; unsigned int b = 1; printf("%d %d", a < b, a < (int)b);