Computer Science Department/JUST

CS 215

Dr. Monther Aldwairi

Quize 6 (7/16/2008)

 

Name:__________________________________________

 

What is the output of the following code?

 

    Sub Main()

        Dim i As Integer = 23

        Dim RndObject As Random = New Random()

 

        Console.WriteLine(i)

        Console.WriteLine(test(RndObject.Next(1), i))

        Console.WriteLine(i)

        Console.WriteLine(test(RndObject.Next(5, 6), i))

        Console.WriteLine(i)

        Console.WriteLine(IntDiv(10, RndObject.Next(6)))

        Console.WriteLine(i)

        Console.WriteLine(IntDiv(i + 1, i))

        Console.WriteLine(IntDiv(i + 1, test(i + 1, i)))

        Console.WriteLine(i)

 

    End Sub

 

    Function test(ByRef x As Integer, ByRef y As Integer) As Integer

        y = y Mod (x + 8)

        Return y * x

    End Function

    Function IntDiv(ByRef x As Integer, ByVal y As Integer) As Integer

        Return 7 \ x

    End Function

 

 

Answers:

 

23

0

7

35

7

0

7

0

0

7