What is the output of: printf("%d\n", sizeof(array)); for int array[10];?

Disable ads (and more) with a membership for a one time $4.99 payment

Study for the University of Central Florida (UCF) EGN3211 Exam. Prepare with comprehensive material, flashcards, and multiple choice questions. Enhance your understanding and excel in your exam!

The expression sizeof(array) in the context of int array[10]; returns the total size in bytes of the entire array, not just the number of elements it contains.

In C, an int typically occupies 4 bytes on most platforms (though this can vary depending on the architecture). Since the declared array has 10 integers, the total size of the array is calculated as:

[ \text{Number of elements} \times \text{Size of each element} = 10 \times 4 \text{ bytes} = 40 \text{ bytes} ]

Therefore, the output of the printf statement will be 40, which is why this choice is the correct answer. The output does not depend on the content of the array; it solely depends on the data type and the number of elements defined in the array.