C Programming · Question 13 · Hard
What will be the output of the following C program?
#include <stdio.h>
#define SQ(x) x * x
int main(void) {
printf("%d", SQ(2 + 3));
return 0;
}
- 25
- 11
- 13
- 10
Answer and explanation
Answer: B. 11
Explanation: Macros are plain text substitution, so SQ(2 + 3) becomes 2 + 3 * 2 + 3. By precedence this is 2 + 6 + 3 = 11. Writing ((x) * (x)) would give 25.
Previous: What will be the output of the following C program? · Next: What will be the output of the following C program?
Practise c programming
Try a fresh set of c programming questions with an explanation after every answer, free and without signing up: C Programming practice. Or sit a full placement mock test.
More c programming questions
- What will be the output of the following C program?
- What will be the output of the following C program?
- What will be the output of the following C program?
- What will be the output of the following C program?
- What will be the output of the following C program?
- What will be the output of the following C program?
- What will be the output of the following C program?
- What will be the output of the following C program?
- What will be the output of the following C program?
- What will be the output of the following C program?
More technical & programming practice
Java · Python · Data Structures · Algorithms · Object-Oriented Programming · DBMS · SQL · Operating Systems
LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge