random number grid using matrix and for loop

Hello I am currently barely starting out with c++ and am stuck on the second part of an assignment that requires me to create a grid of randomly generated numbers using a matrix and for loop and then transpose it to the second diagonal. Can anyone look at my code and see where I can generate the grid? When I output the first half is correct but the second part only generates a random line of numbers. *sorry if it is messy, again I am only a beginner!!!*

#include <iostream>
#include <time.h>

using namespace std;

void displayArray(int toDisplay[9][9]) {
for (int row = 0; row < 9; ++row) {
for (int col = 0; col < 9; ++col) {
int value = toDisplay[row][col];
cout << value << " ";
}
cout << endl;
}
}

void SwapDiagonal1(int toSwap[9][9], int myRow, int myCol) {
// store my value
int tmp = toSwap[myRow][myCol];
//figure out the other coordinates
int otherRow = myCol;
int otherCol = myRow;
//replace my values with the other
toSwap[myRow][myCol] = toSwap[otherRow][otherCol];
//replace with the store value
toSwap[otherRow][otherCol] = tmp;

}

int main() {
// set randomness seed
srand(time(NULL));

int matrix[9][9];
int matrix2[10][10];
int helper = 10;
int tmp[9][9];
//int i;
// int j;

for (int row = 0; row < 9; ++row) {
for (int col = 0; col < 9; ++col) {
matrix[row][col] = helper;
helper += 1;

// int random = 10 + rand() % 100;
}
}
cout << "before:" << endl;
displayArray(matrix);
//transpose
//int diagonal = 90
for (int row = 0; row < 9; ++row) {
for (int col = 0; col < 9; ++col) {
//matrix[row][col] = 0;
tmp[row][col] = matrix[8 - col][8 - row];

}
cout << endl;
}
cout << "after:\n";
displayArray(tmp);
cout <<"before:"<< endl;
// displayArray(matrix);
for (int row = 0; row < 9; ++row) {
for (int col = 0; col < 9; ++col) {
int random = 10 + rand() % 100;
matrix2[row][col] = random;
cout<<matrix2[row][col];
}
}
cin.ignore();
cin.get();
return 0;

}
Topic archived. No new replies allowed.