logo CodeStepByStep logo

ArrayMystery3

Language/Type: C# arrays array mystery

Consider the following method:

public static void Mystery3(int[] nums)
{
    for (int i = 0; i < nums.Length - 1; i++)
    {
        if (nums[i] > nums[i + 1])
        {
            nums[i + 1]++;
        }
    }
}

For each array below, indicate what the array's contents would be after the method Mystery were called and passed that array as its parameter.

{42}
{14, 7}
{7, 1, 3, 2, 0, 4}
{10, 8, 9, 5, 5}
{12, 11, 10, 10, 8, 7}

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.