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

Arrays and Structures · Part 8

Chapter 3: 4 · Computer Science

element of the first row matrix[ ][ ]= ;// Assign to the second element of the first row matrix[ ][ ]= ;// Assign to the third element of the second row matrix[ ][ ]= ;// Assign to the first element of the fourth row Chapter Page - - #include<iostream> #include<conio> using namespace std; int main() int row, col, m1[ ][ ], m2[ ][ ], sum[ ][ ]; cout<<"Enter the number of rows : "; cin>>row; cout<<"Enter the number of columns : "; cin>>col; cout<< "Enter the elements of first matrix: "<<endl; for (int i = ;i<row;i++ ) for (int j = ;j <col;j++ ) cin>>m1[i][j]; cout<< "Enter the elements of second matrix: "<<endl; for (int i = ;i<row;i++ ) for (int j = ;j<col;j++ ) cin>>m2[i][j]; cout<<"Output: "<<endl; for (int i = ;i<row;i++ ) for (int j = ;j<col;j++ ) sum[i][j]=m1[i][j]+m2[i][j]; cout<<sum[i][j]<<" "; cout<<endl<<endl; getch(); return ; Write a program to perform addition of two matrices Enter the number of rows : Enter the number of column : Enter the elements of first matrix: Enter the elements of second matrix: Output: Chapter Page - - . . Memory representation of -D array Normally, the two-dimensional array can be viewed as a matrix. The conceptual view of a -D array is shown below: int A[ ][ ]; A[ ][ ] A[ ][ ] A[ ][ ] A[ ][ ] A[ ][ ] A[ ][ ] A[ ][ ] A[ ][ ] A[ ][ ] A[ ][ ] A[ ][ ] A[ ][ ] In the above example, the -D array name A has rows and columns.

Like one-dimensional, the -D array elements are stored in continuous memory. There are two types of -D array memory representations. They are: • Row-Major order • Column-Major order For example int A[ ][ ]={ { , , }, { , , }, { , , }, { , , } } Row Major order In row-major order, all the elements are stored row by row in continuous memory locations, that is, all the elements in first row, then in the second row and so on. The memory representation of row major order is as shown below; Row

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 →