Ask your own question, for FREE!
Mathematics 7 Online
OpenStudy (anonymous):

Help? Modify the declaration int list[2][3]; so that list[0][1] is initialized to -2 , and all other elements are initialized to 0.

OpenStudy (anonymous):

@jim_thompson5910

OpenStudy (anonymous):

Any ideas @helpme1.2

OpenStudy (kc_kennylau):

int list[2][3]={{0,-2,0},{0,0,0}}; i think

OpenStudy (anonymous):

int list [2][3]={{0,-2, 0},{0,0,0}}; for (int i=0; i<2;i++){ for (int j=0; j<3; j++){ cout <<list[i][j]; }cout<<endl; }

OpenStudy (anonymous):

Well if thats true how would that work for this? int list[2][5][7]; Write an array loop that will display the value of every element of the array.

OpenStudy (anonymous):

list[2][5][7] is three denominational array list[2][3] is 2d

OpenStudy (anonymous):

Okay yeah I knew that much. How would you set it up though?

OpenStudy (kc_kennylau):

sorry it should be: \(\color{blue}{\mbox{int }} \mbox{list}\color{red}{\mbox{[ ][ ]}}\mbox=\color{red}{\{\{}0,-2,0\color{red}\},\color{red}\{0,0,0\color{red}\}\color{red}\};\) (I tested it)

OpenStudy (kc_kennylau):

And the question tells us to modify the declaration, so I think that it should be done in only 1 line.

OpenStudy (anonymous):

write 3 loops

OpenStudy (anonymous):

int list [2][3][5]={?}; for (int i=0; i<2;i++){ for (int j=0; j<3; j++){ for (int j=0; j<5; j++){ cout <<list[i][j]; }cout<<endl; }

OpenStudy (anonymous):

Like that?

OpenStudy (kc_kennylau):

I tested my declaration. It worked. And the question asks for declaration. Not a bunch of for loops.

OpenStudy (anonymous):

for (int i=0; i<2;i++){ for (int j=0; j<3; j++){ for (int m=0; m<5; m++){ cout <<list[i][j][m]; }cout<<endl; }

OpenStudy (anonymous):

you can use this, but like @kc_kennylau said, you probably don't need to use loops

OpenStudy (anonymous):

Thanks guys! :D

OpenStudy (kc_kennylau):

no problem :)

OpenStudy (anonymous):

you're welcome

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!