Karanbir S.

asked • 04/22/21

Please help me with these questions.

nt[, ] arr = new int[4, 5];

int a = 0;

foreach (int i in arr)

{

Console.Write(i + " ");

}


Console.WriteLine("\n");

for (int i = 0; i < arr.GetLength(0); i++)

{

for (int j = 0; j < arr.GetLength(1); j++)

{

a += 5;

arr[i, j] = a;

}

}



for (int i = 0; i < arr.GetLength(0); i++)

{

for (int j = 0; j < arr.GetLength(1); j++)

{

Console.Write(arr[i, j] + " ");

}

}

  1. What is the name of the array in this block of code? 
  2. What is the data type of the array in this program? 
  3. Draw and fill a table to represent the array in this program.
  4. Why do you think the first row of output is all 0’s? 
  5. What is the value of GetLength(0)?
  6. What is the value of GetLenght(1)? 


1 Expert Answer

By:

Patrick B. answered • 04/22/21

Tutor
4.7 (31)

Math and computer tutor/teacher

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.