Given the following macro definitionsdefine height 3define


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}};
    }
}

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: Given the following macro definitionsdefine height 3define
Reference No:- TGS01190603

Expected delivery within 24 Hours