You are on page 1of 4

#include<stdio.

h>

int main()

int r1,c1,x,y;

printf("Enter the order of matrix \n");

scanf("%d %d",&r1,&c1);

int M1[r1][c1],M2[r1][c1],sumM[r1][c1];

printf("Enter all the element for 'A' matrix of order %d X %d \n",r1,c1);

for(x=0;x<r1;x++)

for(y=0;y<c1;y++)

printf("a%d%d = ",x,y);

scanf("%d/t",&M1[x][y]);

printf("\n");

printf("Enter all the element for 'B' matrix of order %d X %d \n",r1,c1);

for(x=0;x<r1;x++)

for(y=0;y<c1;y++)

printf("b%d%d = ",x,y);

scanf("%d/t",&M2[x][y]);

printf("\n");

}
printf("Sum of the Matrix 'A' and Matrix 'B' is:\n");

for(x=0;x<r1;x++)

for(y=0;y<c1;y++)

sumM[x][y]=M1[x][y]+M2[x][y];

if(sumM[x][y]<0)

printf("%d ",sumM[x][y]);

else

printf(" %d ",sumM[x][y]);

printf("\n");

Enter the order of matrix

Enter all the element for 'A' matrix of order 2 X 2

a00 = 9

a01 = 3

a10 = 8

a11 = 4
Enter all the element for 'B' matrix of order 2 X 2

b00 = 7

b01 = 4

b10 = 2

b11 = 9

Sum of the Matrix 'A' and Matrix 'B' is:

16 7

10 13

--------------------------------

Process exited after 78.27 seconds with return value 0

Press any key to continue . . .

Enter the order of matrix

Enter all the element for 'A' matrix of order 3 X 2

a00 = 7

a01 = 0

a10 = 9

a11 = 0

a20 = 8

a21 = 7
Enter all the element for 'B' matrix of order 3 X 2

b00 = 9

b01 = 7

b10 = 0

b11 = 4

b20 = 7

b21 = 7

Sum of the Matrix 'A' and Matrix 'B' is:

16 7

9 4

15 14

--------------------------------

Process exited after 39.21 seconds with return value 0

Press any key to continue . . .

You might also like