logo CodeStepByStep logo

ParameterMysterySection2

Language/Type: C# parameters return

The following console program uses parameters and produces eight lines of output. What are they?

public class ParameterMysterySection2
{
    public static void Main()
    {
        int a = 137;
        int b = 42;

        Console.WriteLine("a = " + a);
        Foo(b);
        Console.WriteLine("a = " + a);
        Console.WriteLine("b = " + b);

        a = Bar(b, a + b);  
        Console.WriteLine("a = " + a);
        a = Bar(a, b);  
        Console.WriteLine("a = " + a);
    }

    public static void Foo(int a)
    {
        Console.WriteLine("a = " + a);
        a = 160;
    }

    public static int Bar(int c, int b)
    {
        int d = b - c;
        Console.WriteLine("d = " + d);
        return d % 10;
    }
}
line 1
line 2
line 3
line 4
line 5
line 6
line 7
line 8

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.