write a program in c++ using function to find the addition of two matrices
Answers
Answered by
1
cout<<"Enter matrix 1 elements :";
for(i=0; i<3; i++)
{ for(j=0; j<3; j++)
{ cin>>mat1[i][j];
} }
cout<<"Enter matrix 2 elements :";
for(i=0; i<3; i++) {
for(j=0; j<3; j++) {
cin>>mat2[i][j];
} }
cout<<"Adding the two matrix to form the third matrix .....\n";
for(i=0; i<3; i++) {
for(j=0; j<3; j++) { mat3[i][j]=mat1[i][j]+mat2[i][j];
} }
cout<<"The two matrix added successfully...!!"; cout<<"The new matrix will be :\n";
for(i=0; i<3; i++) {
for(j=0; j<3; j++)
{
cout<<mat3[i][j]<<" ";
} cout<<"\n";
}
getch();
for(i=0; i<3; i++)
{ for(j=0; j<3; j++)
{ cin>>mat1[i][j];
} }
cout<<"Enter matrix 2 elements :";
for(i=0; i<3; i++) {
for(j=0; j<3; j++) {
cin>>mat2[i][j];
} }
cout<<"Adding the two matrix to form the third matrix .....\n";
for(i=0; i<3; i++) {
for(j=0; j<3; j++) { mat3[i][j]=mat1[i][j]+mat2[i][j];
} }
cout<<"The two matrix added successfully...!!"; cout<<"The new matrix will be :\n";
for(i=0; i<3; i++) {
for(j=0; j<3; j++)
{
cout<<mat3[i][j]<<" ";
} cout<<"\n";
}
getch();
Similar questions
Math,
8 months ago
Math,
8 months ago
Science,
1 year ago
Math,
1 year ago
Social Sciences,
1 year ago