ProgrammingModerate

In a 2D array with int a[5][5], what is the total number of bytes in one row when int is 4 bytes?

  1. A. 20
  2. B. 5
  3. C. 25
  4. D. 16

Correct answer: A. 20

A row of int a[5][5] is 5 ints, so sizeof a[0] = 5 x 4 = 20 bytes. 25 is the element count of the whole array, and 5 counts the elements in a row instead of bytes.

More C Programming questions

Exams that ask this topic