ROW COLUMN SUM IN 2D ARRAY SUM


#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int i,j,na,br,bc,r,c,k,s,a[50][50],b[50][50],e[50][50];
cout<<“Enter limit A”<<endl;
cin>>r>>c;
cout<<“Enter Limit B”<<endl;
cin>>br>>bc;
if(c==br)
{
cout<<“Enter Array A”<<endl;
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
cin>>a[i][j];

}
}
cout<<“Enter Array B”<<endl;
for(i=0;i<br;i++)
{
for(j=0;j<bc;j++)
{
cin>>b[i][j];
}
}
if(c==br)
{
for(i=0;i<r;i++)
{
for(j=0;j<bc;j++)
{
e[i][j]=0;
for(k=0;k<c;k++)
{
e[i][j] = e[i][j] + a[i][k]*b[k][j];
}
}
}
}
for(i=0;i<r;i++)
{ cout<<endl;
for(j=0;j<bc;j++)
{
cout<<” “<<e[i][j];
}
}
}
else
cout<<“INCORRECT DIMENSION FOR ARRAY”<<endl;
getch();
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s