Featured
- Get link
- X
- Other Apps
C++ program to print sum of two matrices
//C++ program to sum two matrices
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int matrix1[3][4],matrix2[3][4],matrix3[3][4];
int i,j;
cout<<"\nEnter numbers to fill matrix 1\n";
for(i=0;i<3;i++)
{
for(j=0;j<4;j++)
{
cin>>matrix1[i][j];
}
}
cout<<"\nEnter numbers to fill matrix 2\n";
for(i=0;i<3;i++)
{
for(j=0;j<4;j++)
{
cin>>matrix2[i][j];
}
}
cout<<"Original Matrix 1:\n";
for(i=0;i<3;i++)
{
for(j=0;j<4;j++)
{
cout<<matrix1[i][j]<<" ";
}
cout<<"\n";
}
cout<<"\n\nOriginal Matrix 2:\n";
for(i=0;i<3;i++)
{
for(j=0;j<4;j++)
{
cout<<matrix2[i][j]<<" ";
}
cout<<"\n";
}
cout<<"\n\nSum of Matrix 1 and Matrix 2:\n";
for(i=0;i<3;i++)
{
for(j=0;j<4;j++)
{
matrix3[i][j]=matrix1[i][j]+matrix2[i][j];
cout<<matrix3[i][j]<<" ";
}
cout<<"\n";
}
getch();
}
- Get link
- X
- Other Apps
Labels:
c program to add two matrix
C++ program to print sum of two matrices
matrix sum program in c programming
Popular Posts
C++ program to display numbers which get reversed after multiplying by 4
- Get link
- X
- Other Apps
Comments
Post a Comment