Tuesday, September 17, 2013

C++ Program to multiply two matrices with Output

Program


#include<iostream>
using namespace std;
int main(){
int i,j,a[3][3],b[3][3],c[3][3];
cout<<"Enter first matrix";
for(i=0;i<3;i++){
    for(j=0;j<3;j++){
        cin>>a[i][j];
    }
    cout<<endl;
}
cout<<"Enter second matrix";
for(i=0;i<3;i++){
    for(j=0;j<3;j++){
        cin>>b[i][j];
    }
cout<<endl;
}
for(i=0;i<3;i++){
    for(j=0;j<3;j++){
c[i][j]=a[i][j]*b[i][j];
    }
}
for(i=0;i<3;i++){
    for(j=0;j<3;j++){
        cout<<c[i][j]<<" ";
    }
cout<<endl;
}
return 0;
}



Output:-



No comments:

Post a Comment

Ads Inside Post