Array question
Dec 16, 2016 at 11:40pm
Hello all, some questions about the array here. What's the purpose of make the mode array = 0? then mode[0][0] = 1? Thanks for your time.
1 2 3 4
|
for (i = 0; i < 2; i++)
for (j = 0; j < 10; j++)
mode[j][i] = 0;
mode[0][0] = 1;
|
Dec 17, 2016 at 12:13am
1 2 3
|
for (i = 0; i < 2; i++)
for (j = 0; j < 10; j++)
mode[j][i] = 0;
|
This will set every element in mode to 0.
You could also do this:
1 2
|
const int ROWS = 2, COLUMNS = 10;
int mode[ROWS][COLUMNS] = { 0 };
|
mode[0][0] = 1;
This will set the element in the first row and first column to 1.
Dec 17, 2016 at 6:05pm
Thank you Integralfx, do we have to set array to zero every time before we use them?
Topic archived. No new replies allowed.