Ticker

6/recent/ticker-posts

Program to input two mtarices, add them and display in proper format in c programming _source code

 #include<stdio.h>
#include<conio.h>
void main(){
int i,j,a[5][5],b[5][5],s[5][5],m,n;
printf("enter the size of row and column :");
scanf("%d%d",&m,&n);
printf("enter the first matrix elements:\n");
for(i=0;i<m;i++){
for(j=0;j<n;j++)
scanf("%d",&a[i][j]);
}
printf("enter the second matrix element : \n");
for(i=0;i<m;i++){
for(j=0;j<n;j++)
scanf("%d",&b[i][j]);
}

for(i=0;i<m;i++){
for(j=0;j<n;j++)
s[i][j] =a[i][j]+b[i][j];
}
printf("\nthe sum of 2 matrix : \n");
for(i=0;i<m;i++){
for(j=0;j<n;j++)
printf("%d\t",s[i][j]);
printf("\n");
}
getch();
}




Reactions

Post a Comment

0 Comments