Addition Multiplication of Two Matrices in C

Example 1

Output

``` First Matrix:
5 6 7
8 9 10
3 1 2
Second Matrix:
1 2 3
4 5 6
7 8 9

Choose the matrix operation,
----------------------
2. Subtraction
3. Multiplication
4. Transpose
5. Exit
----------------------
Sum of matrix:
6 8 10
12 14 16
10 9 11

Choose the matrix operation,
----------------------
2. Subtraction
3. Multiplication
4. Transpose
5. Exit
----------------------
Subtraction of matrix:
4 4 4
4 4 4
-4 -7 -7

Choose the matrix operation,
----------------------
2. Subtraction
3. Multiplication
4. Transpose
5. Exit
----------------------
Multiplication of matrix:
78 96 114
114 141 168
21 27 33

Choose the matrix operation,
----------------------
2. Subtraction
3. Multiplication
4. Transpose
5. Exit
----------------------
Transpose of the first matrix:
5 8 3
6 9 1
7 10 2
Transpose of the second matrix:
1 4 7
2 5 8
3 6 9

Choose the matrix operation,
----------------------
2. Subtraction
3. Multiplication
4. Transpose
5. Exit
----------------------
Invalid input.

Choose the matrix operation,
----------------------
2. Subtraction
3. Multiplication
4. Transpose
5. Exit
----------------------
Thank You.
```

Example 2

Output

``` Enter no. of rows and columns in matrix A: 3 3
Enter no. of rows and columns in matrix B: 3 3
Enter elements of matrix A:
1 1 1
2 2 2
3 3 3
Enter elements of matrix B:
2 2 2
2 2 2
2 2 2