0

Hey guys!

I have an encryption project for school and i have to randomly generate a 3x3 matrix.

I know how to assign the values to the 2d array but i am unsure how to return the array.

I know it is possible to return a vector of a vector but i am no where near learning vectors yet.

Here is my defective code:

```
int* matrixGenerator (int * matrix)
{
srand (time(0));
int matrix [3][3];
int x = 0, y = 0;
while (x < 3)
{
while (y < 3)
{
matrix [x][y] = rand() % 10000;
++y;
}
y = 0;
++x;
}
for (int l = 0; l < 3; l++)
{
for (int a = 0; a < 3; a ++)
{
cout << matrix [l][a] << " ";
}
cout << endl;
++x;
}
return matrix;
}
```

*Edited 4 Years Ago by Dani*: Code formatting