#include<iostream.h>
#include<conio.h>
#include<stdio.h>
void main()
{
int a[3][3],b[3][3],c[3][3],i,j;
clrscr();
cout<<"\nenter elements of A matrix:";
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
cin>>a[i][j];
}
cout<<"B elents:";
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
cin>>b[i][j];
}
cout<<"\nA=";
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
cout<<a[i][j]<<"\t";
cout<<"\n";
}
cout<<"\nB=";
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
cout<<b[i][j]<<"\t";
cout<<"\n";
}
cout<<"C=A+B=\n";
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
c[i][j]=a[i][j]+b[i][j];
}
// cout<<"c=";
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
cout<<c[i][j]<<"\t";
cout<<"\n";
}
getch();
}
Sunday, 7 December 2014
C++ program to print addition og two matrices
Posted by Madan
Posted on 14:05





