C program to do the addition of two matrices
Code:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
void main() | |
{ | |
int mat1[3][3],mat2[3][3],rmat[3][3]; | |
int i,j; | |
for(i=0;i<3;i++) | |
{ | |
for(j=0;j<3;j++) | |
{ | |
printf("Enter a %dcoloum %drow of matrix1"); | |
scanf("%d",&mat1[i][j]); | |
} | |
} | |
for(i=0;i<3;i++) | |
{ | |
for(j=0;j<3;j++) | |
{ | |
printf("Enter a %dcoloum %drow of matrix2"); | |
scanf("%d",&mat2[i][j]); | |
} | |
} | |
for(i=0;i<3;i++) | |
{ | |
for(j=0;j<3;j++) | |
{ | |
rmat[i][j]=mat1[i][j]+mat2[i][j]; | |
} | |
} | |
for(i=0;i<3;i++) | |
{ | |
for(j=0;j<3;j++) | |
{ | |
printf("%d\t",rmat[i][j]); | |
} | |
printf("\n"); | |
} | |
} |
Comments
Post a Comment
Feel free to leave a comment...