Answer to Question #15148 in C++ for joshuajobin08

Question #15148
i am having a doubt , how to make make matrix in addition but my output should be in this way
1 1 1 1 1 1 2 2 2
1 1 1 + 1 1 1 = 2 2 2
1 1 1 1 1 1 2 2 2
i am able to make single matrix but to make in this way is difficult.
1
Expert's answer
2012-09-25T11:30:11-0400
#include <conio.h>

int main()
{
int a[3][3];
int b[3][3];
int c[3][3];
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
a[i][j]=1;
b[i][j]=1;
}
}

for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
c[i][j]=a[i][j]+b[i][j];
}
}
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
printf("%d",a[i][j]);
}
printf("
");
}
printf("+
");
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
printf("%d",b[i][j]);
}
printf("
");
}
printf("=
");
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
printf("%d",c[i][j]);
}
printf("
");
}

getch();
return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS