logo CodeStepByStep logo

ArrayMystery2

Language/Type: C# arrays array mystery

Consider the following method:

public static void Mystery2(int[] list)
{
    for (int i = 0; i < list.Length - 1; i++)
    {
        if (i % 2 == 0)
        {
            list[i]++;
        }
        else
        {
            list[i]--;
        }
    }
}

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.

{6, 3}
{2, 4, 6}
{1, 2, 3, 4}
{2, 2, 2, 2, 2}
{7, 3, 2, 0, 5, 1}

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.