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.

Expert's answer

#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;

}

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;

}

## Comments

## Leave a comment