A simple CPP Program for matrix multiplication.
Matrix 1- 1 2 3
4 5 6
7 8 9
Matrix 2- 1 2 3
4 5 6
7 8 9
Output- 1 4 9
16 25 36
49 64 81
#include<iostream.h> #include<conio.h> void main() { clrscr(); int m[3][3],n[3][3],o[3][3]; cout << "enter matrix elements" << endl; for (int i=0;i<=2;i++) // m input { for (int j=0;j<=2;j++) { cin >> m[i][j]; } } for (i=0;i<=2;i++) // m output { for (int j=0;j<=2;j++) { cout << m[i][j] << " " ; } cout << endl; } cout << "enter matrix elements" << endl; for (i=0;i<=2;i++) // n input { for (int j=0;j<=2;j++) { cin >> n[i][j] ; } } for (i=0;i<=2;i++) // n output { for (int j=0;j<=2;j++) { cout << n[i][j] << " " ; } cout << endl; } for (i=0;i<=2;i++) // o cal = m*n { for (int j=0;j<=2;j++) { o[i][j]= m[i][j] * n[i][j]; } cout << endl; } for (i=0;i<=2;i++) // output of o { for (int j=0;j<=2;j++) { cout << o[i][j] << " "; } cout << endl; } getch(); }