logo CodeStepByStep logo

arrayMystery3

Language/Type: C++ arrays array mystery

Consider the following function:

void mystery3(int nums[], int length) {
    for (int i = 0; i < 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 function 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.