Assume that an integer occupies 4 bytes. What will be the output of the following C program?

#include <stdio.h>

int main()
{
int a[5] = {1, 2, 3, 4, 5};

```
printf("%d", sizeof(a));

return 0;
```

}
                        

Options

  • A. 4
  • B. 5
  • C. 20
  • D. More than one of the above
  • E. None of the above

Correct Answer (Detailed Explanation is Below)

C. 20

Detailed Explanation

Correct Answer: 20

The array contains 5 integer elements.

Each integer occupies 4 bytes. Therefore, the total memory occupied by the array is:

5 × 4 = 20 bytes

Thus, sizeof(a) returns 20 when a is an actual array in this context.

Exam point: sizeof(array) gives the size of the complete array, not the number of elements.