#include<stdio.h> #include<conio.h> void main(){ int a[3][3],b[3][3]; int i,j; printf("\n Plz., enter values of two matrix to add them..."); printf("\n Enter values of first matrix: "); for ( i = 0; i < 3; i++) { for ( j = 0; j < 3; j++) { scanf("%d",&a[i][j]); } } for ( i = 0; i < 3; i++) { printf("|"); for ( j = 0; j < 3; j++) { printf("\t %d",a[i][j]); } printf("\t |"); printf("\n"); } printf("\n Enter the value of second matrix: "); for ( i = 0; i < 3; i++) { for ( j = 0; j < 3; j++) { scanf("%d",&b[i][j]); } } for ( i = 0; i < 3; i++) { printf("|"); for ( j = 0; j < 3; j++) { printf("\t %d",a[i][j]); } printf("\t |"); printf("\n"); } printf("\n"); printf("The summation of two matrix: "); for ( i = 0; i < 3; i++) { printf("|"); for ( j = 0; j < 3; j++) { printf("\t %d",(a[i][j]+b[i][j])); } printf("\t |"); printf("\n"); } }
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