Code:

//matrix multiplication
#include<iostream>
#include<cmath>
using namespace std;
double** matmulti(int rows1,int columns1,double dynarray1[][3],int rows2,int columns2,double dynarray2[][3]);
int main()
{
int rowsx=3;
int columnsx=3;
int rowsy=3;
int columnsy=3;
double alpha=1.2;float beta=2.3;float gamma=1.4;
double x,y,z;
double rotx[3][3]={{1.00,0,0},
{0,cos(alpha),-sin(alpha)},
{0,sin(alpha),cos(alpha)}
} ;
double roty[3][3]={{cos(beta),0,sin(beta)},
{0,1.00,0},
{-sin(beta),0,cos(beta)}
};
double rotz[3][3]={{cos(gamma),-sin(gamma),0},
{sin(gamma),cos(gamma),0},
{0,0,1.00}
};
double** result=matmulti(rowsx,columnsx,rotx,rowsy,columnsy,roty);
//now I want to multiply this result with the third matrix which I can not do
double** result1=matmulti(rowsx,columnsx,result,rowsy,columnsy,rotz);
}
double** matmulti(int rows1,int columns1,double dynarray1[][3],int rows2,int columns2,double dynarray2[][3])
{
int rows=rows1;
int columns=columns2;
double** result;
result=new double* [rows];
for(int i=0;i<rows;i++)
{
result[i]=new double[columns];
}
//cout<<"\n\n\nresult is \n\n";
if(columns1==rows2){
for(int i=0;i<rows1;i++){
for(int j=0;j<columns2;j++){
for(int k=0;k<rows2;k++){
result[i][j]+=(dynarray1[i][k])*(dynarray2[k][j]);
}
//cout<<result[i][j]<<" ";
}
//cout<<"\n";
}
}else
{
cout<<"Matrices can not be multiplied\n";
exit(-1);
}
return result;
for(int i=0;i<3;i++)
{
delete[] result[i];
}
delete result;
}