ProgrammingModerateTCS NQT · Wipro
What is printed?
What is printed?
#define SHOW(x) printf(#x " = %d", x) int a = 3; SHOW(a * 2 + 1);
- A. a * 2 + 1 = 7
- B. x = 7
- C. a * 2 + 1 = 9
- D. 7 = 7
Correct answer: A. a * 2 + 1 = 7
#x turns the argument's tokens into a string literal, "a * 2 + 1", which is joined to " = %d" by adjacent-literal concatenation. The second x is substituted as an expression, 3 * 2 + 1 = 7. '9' adds before multiplying.
More C Programming questions
- file1.c contains static int count = 5; at file scope. file2.c contains extern int count; and uses count in main. Nothing else defines…
- What is printed? c int a[] = {10, 20, 30, 40, 50}; int p = (int )(&a + 1); int q = &a[1] + 1; printf("%d %d %td", (p - 1), (q - 1), p - q);
- What is printed? c int a = 0, b = 1, c = 2; if (a++ || b-- && ++c) c += 10; printf("%d %d %d", a, b, c);
- What is the output? c int i = 0, s = 0; do { i++; if (i % 2) continue; s += i; } while (i < 7); printf("%d %d", i, s);
- What is printed? c char label(int n) { static char buf[8]; buf[0] = 'A' + n; buf[1] = '0'; return buf; } int main(void) { char a =…
- What is printed? c int i, s = 0; for (i = 1; i < 50; i = i 2 + 1) s += i % 3 ? i : -i; printf("%d %d", s, i);