ProgrammingModerate
int a[2][3]; with two rows and three columns in a variable-length array, what is sizeof(a) on a platform with 4-byte int?
- A. 12
- B. 6
- C. 24
- D. 8
Correct answer: C. 24
The array holds 6 ints of 4 bytes each, which is 24 bytes. sizeof is evaluated at run time for a VLA.
More C Programming questions
- char names[3][6] = {"ab", "cde"}; What is sizeof names[1]?
- Which statement about memset(a, 0, sizeof a) for a 2D int array a[4][5] is correct?
- int a[3][4]; int p = &a[0][0]; Which expression refers to a[2][1]?
- On a machine with 4-byte int, what does sizeof(r) give when int (r)[3] is a pointer to a row of three ints?
- Three rows are each malloc'd separately, and their pointers are stored in an array rowp[3]. Which cleanup order is correct?
- A matrix of n x n values is read and the program needs the sum of all cells above the main diagonal. What is the cost, and is it correct…