logo CodeStepByStep logo

Mystery2d

Language/Type: C# arrays multi-dimensional arrays

Consider the following method:

public static void Mystery2d(int[][] a)
{
    for (int r = 0; r < a.Length; r++)
    {
        for (int c = 0; c < a[0].Length - 1; c++)
        {
            if (a[r][c + 1] > a[r][c])
            {
                a[r][c] = a[r][c + 1];
            }
        }
    }
}

If a two-dimensional array named numbers is initialized to store the following integers, what are its contents after the call shown?

int[][] numbers = {
    {3, 4, 5, 6},
    {4, 5, 6, 7},
    {5, 6, 7, 8}
};
Mystery2d(numbers);
numbers[0][0]
numbers[0][1]
numbers[0][2]
numbers[0][3]
numbers[1][0]
numbers[1][1]
numbers[1][2]
numbers[1][3]
numbers[2][0]
numbers[2][1]
numbers[2][2]
numbers[2][3]

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.