2-D Array In C++
CODE:
#include<iostream>
#include<conio.h>
using namespace std;
void main()
{
int i,j,a[20][20],b[20][20],c[20][20],x,z;
cout<<"Enter no of rows and coloms of matrix A and B :"<<endl;
cin>>x;
cin>>z;
cout<<"Enter the elements of matrix A :"<<endl;
for(i=0;i<x;i++)
{
for(j=0;j<z;j++)
{
cin>>a[i][j];
}
}
cout<<"Enter the elements of matrix B :"<<endl;
for(i=0;i<x;i++)
{
for(j=0;j<z;j++)
{
cin>>b[i][j];
}
}
for(i=0;i<x;i++)
{
for(j=0;j<z;j++)
{
c[i][j]=a[i][j]*b[i][j];
}
}
cout<<"The resultant matrix is :"<<endl;
for(i=0;i<x;i++)
{
for(j=0;j<z;j++)
{
cout<<c[i][j]<<"\t";
}
cout<<endl;
}
getch();
}