Write a program of matrices addition

//this is a program of matrices addition
#include<iostream>
#include<conio.h>

using namespace std;

int main()
{
int a[2][2],b[2][2],c[2][2],i,j;

cout<<"\n\nAccepting the array Elements: ";

cout<<"\n\nEnter the elements of array A: ";
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
cin>>a[i][j];
}

cout<<"\n\nEnter the elements of array B: ";
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
cin>>b[i][j];
}


//Performing addition

for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
c[i][j]=a[i][j]+b[i][j];
}

cout<<"\n\nDisplaying the addition of arrays A and B in Array C: ";

for(i=0;i<2;i++)
{
cout<<"\n";
for(j=0;j<2;j++)
cout<<" "<<c[i][j];
}

getch();


}

Previous
Next Post »