Given the following macro definitions
#define HEIGHT 3
#define WIDTH 5
There is a multidimensional array called anArray declared as follows:
int anArray[HEIGHT][WIDTH];
Consider the following code segment:
for (int n=0;n < HEIGHT; n++) {
//TODO: complete the for loop to populate all index numbers with the value 0.
}
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 < HEIGHT; n++) { for (int m=0; m < WIDTH; m++) { }
anArray[n][m] = 0;
}
|
D. |
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}}; } } |