ProgrammingModerateTCS NQT · Infosys pattern
What is printed?
What is printed?
#define SQUARE(x) x * x
printf("%d", SQUARE(2 + 3));- A. 11
- B. 13
- C. 25
- D. 10
Correct answer: A. 11
A macro substitutes text, so SQUARE(2 + 3) becomes 2 + 3 * 2 + 3 = 2 + 6 + 3 = 11. Writing #define SQUARE(x) ((x) * (x)) would give 25.
More C Programming questions
- What is printed when count() is called three times in a row? c void count(void) { static int c = 0; c++; printf("%d ", c); }
- What is printed? c int a[5] = {1, 2}; printf("%d", a[3]);
- What is printed? c int x = 5; printf("%d", x > 3 ? x < 10 ? 1 : 2 : 3);
- What is printed? c int i; for (i = 0; i < 10; i += 3) printf("%d ", i);
- What is printed? c int x = 10; int p = &x; int q = &p; q = 20; printf("%d", x);
- What is printed? c char s[20] = "Code"; strcat(s, "Hub"); printf("%zu", strlen(s));