Question 12
Back to Exercise
What is the output of the following program, compiled as C23?
#include <stdio.h>
int main(void) {
constexpr int SIZE = 4;
auto half = SIZE / 2.0;
typeof(half) twice = half * 2;
printf("%.1f %zu %.1f\n", half, sizeof twice, twice);
return 0;
}
- A 2.0 8 4.0 Correct
- B 2.0 4 4.0
- C 2 8 4
- D Compilation error
Correct Answer: Option A
SIZE / 2.0 is a double, so auto deduces double, and typeof(half) is double too (8 bytes).
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!