#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
void main()
{
clrscr();
int m[3][3] = {{1,2,4},{2,6,2},{3,5,3}}, n[3][3] = {{3,1,4},{7,2,5},{9,3,8}};
int r, c;
cout<<endl<<"Matrix M\n--------\n";
for (r=0; r<3; r++)
{
for (c=0; c<3; c++)
{
cout<<setw(3)<<m[r][c];
}
cout<<"\n";
}
cout<<"\nMatrix N\n--------\n";
for (r=0; r<3; r++)
{
for (c=0; c<3; c++)
{
cout<<setw(3)<<n[r][c];
}
cout<<"\n";
}
cout<<"\nSum of Matrices\n--------\n";
for (r=0; r<3; r++)
{
for (c=0; c<3; c++)
{
cout<<setw(3)<<m[r][c] + n[r][c];
}
cout<<"\n";
}
cout<<"\nSum of Matrices\n--------\n";
for (r=0; r<3; r++)
{
for (c=0; c<3; c++)
{
cout<<setw(3)<<m[r][c] + n[r][c];
}
cout<<"\n";
}
getch();
}
For Further Reading,
0 comments:
Post a Comment