Question 2
Back to Exercise
What is the output of the following C program?
#include <stdio.h>
#define SQUARE(x) x * x
static inline int square(int x) { return x * x; }
int main(void) {
printf("%d %d\n", SQUARE(2 + 3), square(2 + 3));
return 0;
}
- A 11 25 Correct
- B 25 25
- C 11 11
- D 25 11
Correct Answer: Option A
The macro pastes text: 2 + 3 * 2 + 3 = 11. The function receives the value 5 and returns 25. Macros need brackets everywhere – ((x) * (x)) – or, better, an inline function.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!