📖 Samacheer Kalvi · 11th TN - English Medium · Computer Science · Page 212question

Arrays and Structures · Part 7

Chapter 3: 4 · Computer Science

collection of similar elements where the elements are stored in certain number of rows and columns. An example m × n matrix where m denotes the number of rows and n denotes the number of columns is shown in Figure12. int arr[ ][ ]; arr[ ] [ ] arr[ ] [ ] arr[ ] [ ] arr[ ] [ ] arr[ ] [ ] arr[ ] [ ] arr[ ] [ ] arr[ ] [ ] arr[ ] [ ] 2D array conceptual memory representation The array arr can be coneptually viewed in matrix form with rows and coloumns. The point to be noted here is since the subscript starts with arr [ ][ ] represents the first element.

Column subscript Row subscript Figure . . . Declaration of -D array The declaration of a -D array is data-type [row-size][col-size]; In the above declaration, data-type refers to any valid C++ data-type, refers to the name of the -D array, row-size refers to the number of rows and col-size refers to the number of columns in the -D array.

For example int A[ ][ ]; In the above example, A is a -D array, denotes the number of rows and denotes the number of columns. This array can hold a maximum of elements. Note Array size must be an unsigned integer value which is greater than . In arrays, column size is compulsory but row size is optional.

Chapter Page - - Other examples of -D array are: int A[ ][ ]; float x[ ][ ]; char name[ ][ ]; . . Initialization of Two-Dimensional array The array can be initialized in more than one way at the time of -D array declaration. For example int matrix[ ][ ]={ { , , },// Initializes row { , , },// Initializes row { , , },// Initializes row { , , }// Initializes row }; int matrix[ ][ ]={ , , , , , , , , , , , }; Array’s row size is optional but column size is compulsory.

For example int matrix[][ ]={ { , , },// row { , , },// row { , , },// row { , , }// row }; . . Accessing the two-dimensional array Two-dimensional array uses two index values to access a particular element in it, where the first index specifies the row value and second index specifies the column value. matrix[ ][ ]= ;// Assign to the first

Related topics

Have a question about this topic?

Get an AI answer grounded in your actual textbook — with the exact page reference.

Ask AI about this topic →