logo CodeStepByStep logo

LoopMysteryExam3

Language/Type: VB while return

For each call of the function below, write the output that is printed and the value that is returned:

Public Function LoopMysteryExam3(x As Integer, y As Integer)
    Dim z As Integer = x + y
    While x > 0 And y > 0
        x = x - y
        y -= 1
        Console.Write(x & " " & y & " ")
    End While
    Console.WriteLine(y)
    Return z
End Function
LoopMysteryExam3(7, 5) output
LoopMysteryExam3(7, 5) return
LoopMysteryExam3(20, 4) output
LoopMysteryExam3(20, 4) return
LoopMysteryExam3(40, 10) output
LoopMysteryExam3(40, 10) return

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.