Question 3
Back to Exercise
What is the output of the following C program?
#include <stdio.h>
int main(void) {
int a[6];
printf("%td %td\n", (&a + 1) - &a, (char *) (&a + 1) - (char *) a);
return 0;
}
- A 6 6
- B 1 6
- C 24 24
- D 1 24 Correct
Correct Answer: Option D
&a points to the whole array (int (*)[6]). Subtracting two such pointers counts whole arrays: 1. Measured in bytes (char *), the jump is the full array size: 6 × 4 = 24.
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!