To Takehome Quizzes

                         IT 236 -- Quiz 4 

1. (25 pts.) Use a While loop to add up all the terms
             in the sequence 1, 3, 9, 27, 81, ... , 3 ^ n 
             for terms less than or equal to 1,000,000.
             Use either a console or Windows application.

2. (25 pts.) Explain why using an array containing 100 items 
             is preferable to using the 100 separate variables 
             a0, a1, a2, ... , a99 instead.

3. (25 pts.) Construct the variable trace and predict the output:
             You must show both the trace table and the output for
             full credit.

         Public Sub Main( )
             Dim a( ) As Integer = {45, 32, 67, 37}
             Dim t As Integer

             If a(0) > a(1) Then 
                 t = a(1)
                 a(1) = a(0)
                 a(0) = t
             End If

             If a(1) > a(2) Then 
                 t = a(2)
                 a(2) = a(1)
                 a(1) = t
             End If

             If a(2) > a(3) Then 
                 t = a(3)
                 a(3) = a(2)
                 a(2) = t
             End If

             If a(1) > a(2) Then 
                 t = a(2)
                 a(2) = a(1)
                 a(1) = t
             End If

             For t = 0 To 3
                 Write(a(t) & " ")
             Next
         End Sub

4. (25 pts.) Write a While loop or For loop that copies all of 
             the items in the array a to the multiline textbox 
             txtOutput.  Assume that the array contains 50 items. 
             There should be one item per line.