#include<stdio.h> int main() { int a[3][3],b[3][3],c[3][3]; int i,j; printf("Enter Matrix 1:\n"); for(i=0;i<3;i++){ for(j=0;j<3;j++){ scanf("%d",&a[i][j]); } } printf("Enter Matrix 2:\n"); for(i=0;i<3;i++){ for(j=0;j<3;j++){ scanf("%d",&b[i][j]); } } printf("Matrix 1:\n"); for(i=0;i<3;i++){ for(j=0;j<3;j++){ printf("%d\t",a[i][j]); } printf("\n"); } printf("Matrix 2:\n"); for(i=0;i<3;i++){ for(j=0;j<3;j++){ printf("%d\t",b[i][j]); } printf("\n"); } for(i=0;i<3;i++){ for(j=0;j<3;j++){ c[i][j] = a[i][j] + b [i][j]; } } printf("Matrix 3:\n"); for(i=0;i<3;i++){ for(j=0;j<3;j++){ printf("%d\t",c[i][j]); } printf("\n"); } return 0; }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter