COMP 125: Introductory Programming

Course Examination

Test Date: Monday, March 15, 1999


Part I (10 points)

Determine the output displayed in the picture box when the command button is clicked (assume that the responses are 7 and 11):

  Private Sub cmdDisplay_Click()

Dim a As Single, b As Single
Let a = Val(InputBox("Enter a number"))
Let b = Val(InputBox("Enter another number"))
If a > b then
Let a = a + 1
else
Let b = b + 1
End If
picResults.Print a; b
End Sub


Part II (10 points)

Identify the error in the following program segment:

    Private Sub cmdDisplay_Click()

Dim j As Single, k As Single
Rem Display "OK" if either j or k equals 5
Let j = 2
Let k = 3
If j = 5 Or k Then
picResults.Print "OK"
End If
End Sub


Part III (30 points)

In the following program segment, simplify the code.

  Private Sub cmdDisplay_Click()
    Dim a As Single, b As Single

    PicResults.Cls

    Let a = Val(InputBox("Enter a number"))
    Let b = Val(InputBox("Now enter another number"))
    Let c = Val(InputBox("And now just one more number"))    

    If  a  < b  then
        If  b  <  c  Then
            picResults.print b: "is between"; a; "and"; c
        End If   
    End If
  
  End Sub


Part IV (50 points)

Do either item A or item B (but not both)


Do you have any questions, comments or suggestions? If so, please e-mail them to me at jcorlis@luc.edu.

To return to the COMP 125 (Monday) web site, click here.

To go to my home page, click here.

To go to the home page of Loyola University Chicago, click here.


Jack Corliss
Mathematical and Computer Sciences
Loyola University Chicago
Revised: 15 Janaury 1999