OA. free
Free
Micron Core Computer Science Core Computer Science Medium

QUESTION 23 What would be the size of "storearray" in reference to the code snippet given...

Micron technical mcq question, verified with a worked answer. Free to practise - no sign-up.

QUESTION 23

What would be the size of "storearray" in reference to the code snippet given below?

short storearray[4][3] = { {3}, {4, 6}, {2, 5, 9}};
Choose one option.
Show answer & explanation
Answer: C. 24

The array storearray[4][3] is a 2D array declared as short with 4 rows and 3 columns. Regardless of initialization values, the total number of elements is 4 × 3 = 12 elements. Since short is typically 2 bytes, the total size in bytes is 12 × 2 = 24 bytes. Option A counts only initialized values (7), which is incorrect—array size is determined by declaration, not initialization.

Step-by-step Derivation:
Step 1: Identify array dimensions: storearray[4][3] means 4 rows and 3 columns.
Step 2: Calculate total elements: 4 × 3 = 12 elements.
Step 3: Determine size of each element: short is typically 2 bytes on most systems.
Step 4: Calculate total size in bytes: 12 elements × 2 bytes/element = 24 bytes.
Note: The initialization only provides 7 values (3, 4, 6, 2, 5, 9, plus the implicit 0 from {3}), but array size depends on declaration dimensions, not initialization count.