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.
@jim_thompson5910
Any ideas @helpme1.2
int list[2][3]={{0,-2,0},{0,0,0}}; i think
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; }
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.
list[2][5][7] is three denominational array list[2][3] is 2d
Okay yeah I knew that much. How would you set it up though?
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)
And the question tells us to modify the declaration, so I think that it should be done in only 1 line.
write 3 loops
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; }
Like that?
I tested my declaration. It worked. And the question asks for declaration. Not a bunch of for loops.
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; }
you can use this, but like @kc_kennylau said, you probably don't need to use loops
Thanks guys! :D
no problem :)
you're welcome
Join our real-time social learning platform and learn together with your friends!