#include<stdio.h> #include<conio.h> void main() { int mat1[3][3],mat2[3][3],result[3][3],i,j; clrscr(); printf("Enter First Matrix - \n"); for(i=0;i<3;i++) { for(j=0;j<3;j++) { printf("Enter Element : "); scanf("%d",&mat1[i][j]); } } printf("\nEnter Second Matrix - \n"); for(i=0;i<3;i++) { for(j=0;j<3;j++) { printf("Enter Element : "); scanf("%d",&mat2[i][j]); } } for(i=0;i<3;i++) { for(j=0;j<3;j++) { result[i][j] = mat1[i][j]+mat2[i][j]; } } for(i=0;i<3;i++) { for(j=0;j<3;j++) { printf("%d",result[i][j]); printf(" "); } printf("\n"); } getch(); }
INPUT Enter First Matrix - Enter Element : 4 Enter Element : 4 Enter Element : 4 Enter Element : 4 Enter Element : 4 Enter Element : 4 Enter Element : 4 Enter Element : 4 Enter Element : 4 Enter First Matrix - Enter Element : 2 Enter Element : 2 Enter Element : 2 Enter Element : 2 Enter Element : 2 Enter Element : 2 Enter Element : 2 Enter Element : 2 Enter Element : 2 OUTPUT 6 6 6 6 6 6 6 6 6