I'm working on a program using arrays and I'm trying to figure out
First, with the following array declaration, what is the value stored in the scores[2][2] element?
int scores[3][3] = { {1, 2, 3} };
And also with this array declaration, what is the value stored in the scores[2][3] element?
int scores[5][5] = {5};
Could someone please explain this for me.
First, with the following array declaration, what is the value stored in the scores[2][2] element? |
|
std::cout << scores[3][3];
|
Actually, you have a 2D array (a row/column grid), but have only specified the first line, so the rest get intialised to zero.
So you should expect the code to write zero.
Last edited on
That's what I thought
int scores[3][3] = { {1, 2, 3}, {0, 0, 0}, {0, 0, 0}};
So I should expect the code to write a zero right?