Write A C Code To Add Two Matrix 2x2.
#include <stdio.h> int main () { int arr[2][2],i,j; int ar[2][2],k,l; int sum[2][2]; printf("Enter frst Matrix\n"); for (i=0;i<2;i++) { for (j=0;j<2;j++){ printf("%d row %d Colomn\n",i,j); scanf(" %d",&arr[i][j]); } } printf("Enter 2nd matrix\n"); for (k=0;k<2;k++){ for (l=0;l<2;l++) { printf("%d row %d Colomn\n",k,l); scanf("%d",&ar[k][l]); } } for (i=0;i<2;i++) { printf("\n"); for (j=0;j<2;j++) printf("%d ",arr[i][j]); } printf("\n+"); for (k=0;k<2;k++) { printf("\n"); for (l=0;l<2;l++) printf("%d ",ar[k][l]); } printf("\n\n=\n"); for (k=0;k<2;k++) { for (l=0;l<2;l++) sum[k][l]= arr[k][l] + ar[k][l]; } for (k=0;k<2;k++){ printf("\n"); for (l=0;l<2;l++) printf("%d ",sum[k][l]); } }
0 Comment to " Add Two Matrix 2×2."
Post a Comment