Explore Westonci.ca, the leading Q&A site where experts provide accurate and helpful answers to all your questions. Get the answers you need quickly and accurately from a dedicated community of experts on our Q&A platform. Join our Q&A platform to connect with experts dedicated to providing accurate answers to your questions in various fields.

The HEIGHT variable will be used to hold the index numbers of the rows in a multidimensional array. The WIDTH will be used to hold the index numbers of the columns. Which of the following completed for loop could fill that previously declared anArray multidimensional array with the value 0 in each position?(a) for (int n=0; n < HEIGHT; n++) { for (int m=0; m < WIDTH; m++) { int anArray[0][0]; }}(b) for (int n=0; n < HEIGHT; n++) { for (int m=0; m < WIDTH; m++) { } anArray[n][m] = 0; }(c) for (int n=0; n < WIDTH; n++) { for (int m=0; m < HEIGHT; m++) { int anArray[n][m] = { {0,0,0}{0,0,0}{0,0,0}{0,0,0|}{0,0,0}}; }}(d) for (int n=0; n < HEIGHT; n++) { for (int m=0; m < WIDTH; m++) { anArray[n][m] = 0; }}

Sagot :

Answer:

(d) for (int n=0; n < HEIGHT; n++) { for (int m=0; m < WIDTH; m++) { anArray[n][m] = 0; }}

Explanation:

Given

HEIGHT [tex]\to[/tex] rows

WIDTH [tex]\to[/tex] columns

Required

Fill the array with zeros

Assume the array has already been declared

First, we iterate through the rows; using:

for (int [tex]n=0[/tex]; [tex]n < HEIGHT[/tex]; [tex]n++[/tex]) {

Next, we iterate through the columns

for (int [tex]m=0[/tex]; [tex]m < WIDTH[/tex]; [tex]m++[/tex]) {

Then we fill the array with the iterating variables of rows and the columns

anArray[n][m]

Lastly, close the loops

}}