#include<iostream.h>
#include<conio.h>
void mul(int a[10][10],int b[10][10],int c[20][20],int d,int r,int r1,int c1);
void main()
{
clrscr();
int a[10][10],b[10][10],c[20][20],r,d,i,j,r1,c1;
cout<<"\n";
cout<<"enter size row and column of matix 1";
cout<<"\n\n";
cin>>r;
cout<<"\n";
cin>>d;
cout<<"\n";
cout<<"enter elements";
cout<<"\n";
for(i=0;i<r;i++)
{
for(j=0;j<d;j++)
{
cout<<"\n";
cin>>a[i][j];
}
}
cout<<"\n";
cout<<"enter size of row and column of matix 2";
cout<<"\n\n";
cin>>r1;
cout<<"\n";
cin>>c1;
cout<<"\n";
cout<<"enter elements in matrix 2";
cout<<"\n";
for(i=0;i<r1;i++)
{
for(j=0;j<c1;j++)
{
cout<<"\n";
cin>>b[i][j];
}
}
mul(a,b,c,d,r,r1,c1);
getch();
}
void mul(int a[10][10],int b[10][10],int c[20][20],int d,int r,int r1,int c1)
{
int k,i,j;
if(d!=r1)
{
cout<<"multiplication not possible";
}
else
{
for(i=0;i<r;i++)
{
for(j=0;j<c1;j++)
{
for(k=0;k<r1;k++)
{
c[i][j]+=a[i][k]*b[k][j];
}
}
}
}
cout<<"\n";
cout<<"after multiplication"<<"\n\n";
for(i=0;i<r;i++)
{
for(j=0;j<c1;j++)
{
cout<<c[i][j]<<"\t";
}
}
}
#include<conio.h>
void mul(int a[10][10],int b[10][10],int c[20][20],int d,int r,int r1,int c1);
void main()
{
clrscr();
int a[10][10],b[10][10],c[20][20],r,d,i,j,r1,c1;
cout<<"\n";
cout<<"enter size row and column of matix 1";
cout<<"\n\n";
cin>>r;
cout<<"\n";
cin>>d;
cout<<"\n";
cout<<"enter elements";
cout<<"\n";
for(i=0;i<r;i++)
{
for(j=0;j<d;j++)
{
cout<<"\n";
cin>>a[i][j];
}
}
cout<<"\n";
cout<<"enter size of row and column of matix 2";
cout<<"\n\n";
cin>>r1;
cout<<"\n";
cin>>c1;
cout<<"\n";
cout<<"enter elements in matrix 2";
cout<<"\n";
for(i=0;i<r1;i++)
{
for(j=0;j<c1;j++)
{
cout<<"\n";
cin>>b[i][j];
}
}
mul(a,b,c,d,r,r1,c1);
getch();
}
void mul(int a[10][10],int b[10][10],int c[20][20],int d,int r,int r1,int c1)
{
int k,i,j;
if(d!=r1)
{
cout<<"multiplication not possible";
}
else
{
for(i=0;i<r;i++)
{
for(j=0;j<c1;j++)
{
for(k=0;k<r1;k++)
{
c[i][j]+=a[i][k]*b[k][j];
}
}
}
}
cout<<"\n";
cout<<"after multiplication"<<"\n\n";
for(i=0;i<r;i++)
{
for(j=0;j<c1;j++)
{
cout<<c[i][j]<<"\t";
}
}
}