Walkthrough Do a walkthrough for each of these programs. Include... Output, Line Numbers.

advertisement
Walkthrough
Do a walkthrough for each of these programs. Include Variable Values,
Output, Line Numbers.
1.
2.
3.
4.
5.
Dim Name as String
Name = “Jason”
If Name = “jasson” then
Print “Hi Buddy”
End if
Line # Name Output
1
Jason
No output
2
3f
5
1.
2.
3.
4.
Dim Age, ShoeSize as Integer
for CNT = 1 to4
Age = InputBox(“Enter Age”)
ShoeSize = InputBox(“Enter Shoe Size”)
5.
If Age > ShoeSize then
6.
Print CNT&“ act your age”
7.
Else
8.
Print “Good” & CNT
9.
End if
10. Next CNT
Test Data: 16 ,11, 11,16, 22,22, 0,-1
1. Dim Age, ShoeSize as Integer
2. TotalAge=0
3. For cnt = 0 to 4
4.
Age= val(InputBox(“Enter Age”))
5.
ShoeSize= InputBox(“Shoe Size”)
6.
Total Age = TotalAge + Age
7.
If AverageAge > ShoeSize(ZZ) then
8.
Print “act your age”
9.
Else
10.
Print “Good”
11. End if
12. Next cnt
13. AverageAge = TotalAge / 5
14.
Test Data 11,21, 23, 12, -32,22, 0,0, 32, -4
1. For A = 1 to 4
2.
XY =Inputbox (“Enter a Value”)
3.
If XY > A or XY<0 then
4.
Print XY
5.
Else
6.
Print A
7.
Endif
8. Next A
Test Data: 5,8, 1, -2, 0 ,-31
Line#
1
2 2 2 2
3 3 3 3
4 4 4 4
Age ShoeSize
16
11
11
16
22
22
0
-1
CNT
1
2
3
4
OUTPUT
1aya
5t 5f 5f 5f
6
7 7 7 7
8 8 8
9 9 9 9
10101010
1.
2.
3.
4.
5.
6.
7.
8.
9.
Dim THIS as integer
High = -99
For A = 0 to 6
This = val(inputbox(“EnterValue”))
if This > High then
High = This
msgbox(“Bigger ”)
endif
Next A
10. msgbox(“Biggest was” & High)
TestData: 4,0,3,5,5,99
1. For b = 0 to 6
2.
For W = b +5 to 15
3.
Z=W*b
4.
Next W
5.
If Z>= 100 then
6.
Print Z
7.
Else
8.
Print b,W
9.
End if
10. Next b
Private Sub Command1_Click()
' Bubble Sort.
'declare variables
1.
2.
Dim i, cnt, sample(7), temp, ABC As Integer
3.
4.
5.
'counted loop repetition to input an array of numbers
For i = 0 To 7
sample(i) = Val(InputBox("Enter Number"))
Next i
9.
10.
11.
12.
13.
14.
'Sort the array
For ABC = 0 To 6
For cnt = (ABC + 1) To 7
If sample(ABC) < sample(cnt) Then
'swap
temp = sample(ABC)
sample(ABC) = sample(cnt)
sample(cnt) = temp
End If
Next cnt
Next ABC
15.
16.
17.
18.
' print in new order
For i = 0 To 7
Print sample(i)
Next i
End Sub
6.
7.
8.
Input: 45, 34,23,23,34,22,34,54
Do a walkthrough of the Insertion Sort and the Selection sort with the same data: Input: 45, 34,23,23,34,22,34,54
Download