C program to add two matrices
#include<stdio.h>#include<conio.h>
void main(){ int a[5][5],b[5][5],c[5][5],i,j,m,n; printf("How many rows and columns?"); scanf("%d%d",&m,&n); printf("
Enter first matrix: ");
for(i=0;i<m;++i) for(j=0;j<n;++j) scanf("%d",&a[i][j]);
printf("
Enter second matrix: "); for(i=0;i<m;++i) for(j=0;j<n;++j) scanf("%d",&b[i][j]);
printf("
Matrix after addition:
"); for(i=0;i<m;++i) { for(j=0;j<n;++j) { c[i][j]=a[i][j]+b[i][j]; printf("%d ",c[i][j]); } printf("
"); } getch();}
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.