Untitled
unknown
plain_text
a year ago
955 B
4
Indexable
int i,j; int r1,c1,r2,c2; int m1[10][10],m2[10][10],sum[10][10]; printf("Enter row and column for 1st matrix: \n"); scanf("%d%d",&r1,&c1); printf("Enter row and column for 2nd matrix: \n"); scanf("%d%d",&r2,&c2); if(r1==r2 && c1==c2){ printf("Enter the elements for 1st matrix: \n"); for(i=0;i<r1;i++){ for(j=0;j<c1;j++) { scanf("%d",&m1[i][j]); } } printf("Enter the elements for 2nd matrix: \n"); for(i=0;i<r2;i++){ for(j=0;j<c2;j++) { scanf("%d",&m2[i][j]); } } for(i=0;i<r1;i++){ for(j=0;j<c2;j++){ sum[i][j]=m1[i][j]+m2[i][j]; } } printf("The sum of two matrices is :\n"); for(i=0;i<r1;i++){ for(j=0;j<c2;j++){ printf("%d ",sum[i][j]); } printf(" \n"); } } else{ printf("The order of two matrices are not same!!!"); } }
Editor is loading...
Leave a Comment