Sum of Array Matrix:- Q)Write a program to enter matrix (2) and print the sum of matrices. Note:-You can also create this program in c+...
Sum of Array Matrix:-
Q)Write a program to enter matrix(2) and print the sum of matrices.
Note:-You can also create this program in c++(c plus plus),java,c#(c sharp) languages with the same logic.
Q)Write a program to enter matrix(2) and print the sum of matrices.
Note:-You can also create this program in c++(c plus plus),java,c#(c sharp) languages with the same logic.
void main()
{
int matrix1[10][20],matrix2[10][20],sum[20][30],i,j,row,col;
clrscr();
printf("Enter row and column");
scanf("%d%d",&row,&col);
printf("Enter first Matrix");
for(i=0;i<row;i++)
{
for(j=0;j<col;j++)
{
scanf("%d",&matrix1[i][j]);
}
}
printf("Enter second Matrix");
for(i=0;i<row;i++)
{
for(j=0;j<col;j++)
{
scanf("%d",&matrix2[i][j]);
}}
for(i=0;i<row;i++)
{
for(j=0;j<col;j++)
{
sum[i][j]=matrix1[i][j]+matrix2[i][j];
}}
printf("Sum is");
for(i=0;i<row;i++)
{
for(j=0;j<col;j++)
{
printf("%d",&sum[i][j]);
}
printf("\n");
}
getch();
}
If you have any query then leave your comments and don't forgot to follow me on Google+,Facebook,Twitter.
COMMENTS