Identify the CORRECT declaration of double dimensioned array.

2018

Identify the CORRECT declaration of double dimensioned array.

  1. A.

    int arr[2,2];

  2. B.

    int arr[2][2];

  3. C.

    int arr[2][3][4];

  4. D.

    int *arr[10];

Attempted by 306 students.

Show answer & explanation

Correct answer: B

The correct option is B. In C/C++ programming, a double-dimensioned (two-dimensional) array is declared using separate sets of square brackets for each dimension, following the syntax data_type array_name[row_size][column_size];. Therefore, int arr[2][2]; correctly reserves a matrix of 2 rows and 2 columns.

Explore the full course: Btsc Lab Assistant