How do I code for two 4x4 2D Arrays?

I'm supposed to code for 2 4x4 2D arrays and transpose them and multiply them. However, I only know how to generate one 4x4 2D array and transpose them.

Here's what I know in coding for one 4x4 2D array.


#include <cstdlib>
#include <iostream>
#include <cmath>
#include <ctime>
using namespace std;

int main()
{
/* [] is the array [row][column]*/

int i, j, k, sum, A[4][4], trans[4][4];
srand (time(NULL));

cout << "Array A is : \n"<< endl;
for (i=0; i<4; i++)
{
for (k=0; k<4; k++)
{
A[i][k]= rand() %10;
cout << "\t"<< A[i][k];
}
cout<< endl;
}
{
for(i = 0; i < 4; i++)
{
for(j = 0; j < 4; j++)
{
trans[j][i]=A[i][j];
}
}
}
{

cout << endl << "Transpose of Matrix: \n" << endl;
for(i = 0; i < 4; i++)
{
for(j = 0; j < 4;j++)
{
cout << " " << trans[i][j];
if(j == 4 - 1)
cout << endl;
}
}

}
}

Topic archived. No new replies allowed.