Download presentation
Presentation is loading. Please wait.
1
Arrays
2
What is the output of: Private Sub cmdButton_Click() Dim i As Integer, a(1 To 4) As integer Open "DATA.TXT" For Input As #1 For i = 1 To 4 Input #1, a(i) Next i For i = 4 To 1 Step -2 picBox.Print a(i); Next i End Sub Contents of DATA.TXT: 1,3,5,7
3
Output: 7 3
4
What is the output of: Private Sub cmdButton_Click() Dim i As Integer, a(9) As integer Open "DATA.TXT" For Input As #1 do while not EOF(1) Input #1, x a(x) = x Loop For i = 4 To 9 sum = sum + a(i); Next i Print sum End Sub Contents of DATA.TXT: 1,5,3,7
5
Output: 12
6
What is the output of: Dim a(2 To 9) As Integer, i As Integer, _ k As Integer, sum As Integer For i = 2 To 9 a(i) = i Next i sum = 0 For k = 4 To 6 sum = sum + 10 ^ a(k-2) Next k picBox.Print sum
7
Output: 111000
8
Private Sub cmdButton_Click() On Error GoTo ErrorHandler Dim Q(2 To 7) As Integer p = 4 k = (p + p) / Q(p) Print p + k Exit Sub ErrorHandler: Q(p) = 2 p = Q(p) Q(p) = 2 Resume End sub
9
Output: 4
10
What is the output of: Dim a(-1 to 5) As Single, x As Single Open "DATA.TXT" For Input As #1 Do While Not EOF(1) Input #1, x a(x) = a(x) + 3 Loop Close #1 picBox.Cls picBox.Print a(0); a(2) Contents of DATA.TXT: 0, 1, 5, 2, 0
11
Output: 6 2
12
Dim a(-2 To 5), b As Integer Dim i As Integer, j As Integer Open "DATA.TXT" For Input As #1 num = 0 For i = 3 To 5 Input #1, a(i) Next i For j = -1 To 1 Input #1, k b = b + a(k) Next j picBox.Print b Contents of DATA.TXT: 2, 1, 0, -1, 3, 3
13
Output: 4
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.