logo CodeStepByStep logo

ListMystery2

Language/Type: C# List

Write the contents of each list if it were passed as a parameter to the following method:

public static void Mystery(List list)
{
    for (int i = 0; i < list.Count; i++)
    {
        int n = list[i];
        if (n % 10 == 0)
        {
            list.RemoveAt(i);
            list.Add(n);
        }
    }
}
{1, 20, 3, 40}
{80, 3, 40, 20, 7}
{40, 20, 60, 1, 80, 30}

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.