0% found this document useful (0 votes)
5 views

Matrix Multiplication

Uploaded by

Khushi, 10B,26
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Matrix Multiplication

Uploaded by

Khushi, 10B,26
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

MATRIX MULTIPLICATION:

Program:
#include <iostream>

using namespace std;

int main()

int M1[5][5],M2[5][5],M3[5][5],i,j,k;

cout<<"Enter First Matrix:"<<endl;

for(i=0;i<2;i++)

for(j=0;j<2;j++)

cin>>M1[i][j];

cout<<endl;

cout<<"Enter Second Matrix:"<<endl;

for(i=0;i<2;i++)

for(j=0;j<2;j++)
{

cin>>M2[i][j];

cout<<endl;

cout<<"Matrix Multiplication="<<endl;

for(i=0;i<2;i++)

for(j=0;j<2;j++)

M3[i][j]=0;

for(k=0;k<2;k++)

M3[i][j]+=M1[i][k]*M2[k][j];

cout<<"Display First Matrix"<<endl;

for(i=0;i<2;i++)

for(j=0;j<2;j++)

cout<<M1[i][j]<<" ";

cout<<endl;

cout<<"Display Second Matrix"<<endl;

for(i=0;i<2;i++)

for(j=0;j<2;j++)
{

cout<<M2[i][j]<<" ";

cout<<endl;

cout<<"Multiplication of first & Second Matrix:"<<endl;

for(i=0;i<2;i++)

for(j=0;j<2;j++)

cout<<M3[i][j]<<" ";

cout<<endl;

return 0;

Output:

You might also like