Multiple choice

short testarray[4][3] = { {1}, {2, 3}, {4, 5, 6} }; printf(%dn, sizeof( testarray)); Assuming a short is two bytes long, what will be printed by the above code?

  1. It will not compile because not enough initializers are given.

  2. 6

  3. 7

  4. 12

  5. 24

Reveal answer Fill a bubble to check yourself
E Correct answer
Explanation

testarray[4][3] has 12 elements total (4 rows × 3 columns). Each short is 2 bytes, so sizeof returns 12 × 2 = 24 bytes. The initializer fills only some elements, but sizeof still counts the full array declaration.