Program for Multiplication of Multidimensional arrays
#include<iostream>
#include<conio.h>
int main()
{
int a[5][5],b[5][5],c[5][5];
int main()
{
int a[5][5],b[5][5],c[5][5];
int i,j,k,m,n,p,q;
cout<<"Enter the size of first Array"<<endl;
cin>>mgt;>n;
cout<<"Enter the size of Second Array"<<endl;
cingt;>pgt;>q;
if(n==p)
{
cout<<"Enter the First Array"<<endl;
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
cout<<"Enter the size of first Array"<<endl;
cin>>mgt;>n;
cout<<"Enter the size of Second Array"<<endl;
cingt;>pgt;>q;
if(n==p)
{
cout<<"Enter the First Array"<<endl;
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
cingt;>c[i][j];
}
}
cout<<"Enter the second Array"<<endl;
for (i=0;i<p;i++)
{
for(j=0;j<q;j++)
cingt;>c[i][j];
}
cout<<" Product of two Arrays"<<endl;
for(i=0;i<m;i++)
{
for(j=0;j<q;j++)
c[i][j]=0;
for(k=0;k<p;k++)
c[i][j]=c[i][j]+a[i][k]*b[k][j];
}
for(i=0;i<m;i++)
{
for(j=0;j<q;j++)
cingt;>c[i][j];
}
}
cout<<"Enter the second Array"<<endl;
for (i=0;i<p;i++)
{
for(j=0;j<q;j++)
cingt;>c[i][j];
}
cout<<" Product of two Arrays"<<endl;
for(i=0;i<m;i++)
{
for(j=0;j<q;j++)
c[i][j]=0;
for(k=0;k<p;k++)
c[i][j]=c[i][j]+a[i][k]*b[k][j];
}
for(i=0;i<m;i++)
{
for(j=0;j<q;j++)
{
cout<<c[i][j]<<" ";
}
cout<<endl;
}
cout<<c[i][j]<<" ";
}
cout<<endl;
}
}
else
cout<<"Not possible";
getch();
return 0;
}
No comments :
Post a Comment