In this section, we are going to calculate the sum of two 2 X 2 matrices containing rows and columns.
In this section, we are going to calculate the sum of two 2 X 2 matrices containing rows and columns.In this section, we are going to calculate the sum of two 2 X 2 matrices containing rows and columns. For this , we need to declare two dimensional array of integer type. Here, we prompt the user to input values for two matrices. To make the matrix of 2 X 2, we are using for loop. By the use of for loop, the values will get arrange in rows and columns. After getting both the matrix, the matrices will be added by using the for loop with a[i][j]+b[i][j].
Here is the code:
#include <stdio.h> void main() { |
Output
Enter the First matrix: 1 2 3 4 The First matrix is: 1 2 3 4 Enter the Second matrix: 5 6 7 8 The Second matrix is: 5 6 7 8 The Addition of two matrix is: 6 8 10 12 |