multidimensional arrays- every dimension is


Multidimensional Arrays

- Every dimension is specified in separate brackets

e.g.

int arr[4][3];

This is a two-dimensional array with 4 as row dimension and 3 as a column dimension.

- Multidimensional array can be initialized as follows

e.g.

int arr[4][3] = {{0,1,2},{3,4,5},{6,7,8},{9,10,11}};

  • The nested brackets are optional.

e.g.

int arr[4][3] = { 0,1,2,3,4,5,6,7,8,9,10,11};

int arr[4][3] = {{0},{1},{2},{3}}; // First element of

    rows are 0,1,2,3 and remaining are considered zero.

int arr[4][3] = {1,2,3}; // Initializes first three element of first row as 1,2,3, and remaining elements are considered Zero.

 

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: multidimensional arrays- every dimension is
Reference No:- TGS0309287

Expected delivery within 24 Hours