Question 3
Back to Exercise
What is the output of the following C program?
#include <stdio.h>
#define TOTAL 10 + 5
enum { TOTAL_E = 10 + 5 };
int main(void) {
printf("%d %d\n", TOTAL * 2, TOTAL_E * 2);
return 0;
}
- A 20 30 Correct
- B 30 30
- C 30 20
- D 20 20
Correct Answer: Option A
TOTAL * 2 becomes 10 + 5 * 2 = 20. The enum constant is evaluated once as a value (15), so TOTAL_E * 2 is 30.
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!