Which statement correctly describes a two-dimensional array in C?

Enhance your programming skills with the RECF Programming Test. Features flashcards and multiple choice questions with hints and explanations. Prepare for success!

Multiple Choice

Which statement correctly describes a two-dimensional array in C?

Explanation:
A two-dimensional array in C is a fixed-size grid stored as a single object, defined by two dimensions. Declaring something like int a[3][4] creates three rows, each with four integers. The whole array is a contiguous block of memory, and its type is int [3][4]; in expressions, it can decay to a pointer to its first row, which has type int (*)[4]. You access elements with a[row][column], so a[1][2] refers to the element in the second row, third column. This structure is an array of arrays, not a sequence of independent pointers to rows, and the elements themselves are ints, not pointers. It does not grow automatically; the size is fixed at compile time unless you allocate storage dynamically.

A two-dimensional array in C is a fixed-size grid stored as a single object, defined by two dimensions. Declaring something like int a[3][4] creates three rows, each with four integers. The whole array is a contiguous block of memory, and its type is int [3][4]; in expressions, it can decay to a pointer to its first row, which has type int (*)[4]. You access elements with a[row][column], so a[1][2] refers to the element in the second row, third column. This structure is an array of arrays, not a sequence of independent pointers to rows, and the elements themselves are ints, not pointers. It does not grow automatically; the size is fixed at compile time unless you allocate storage dynamically.

Subscribe

Get the latest from Passetra

You can unsubscribe at any time. Read our privacy policy