Output Tracing:
Dim i As Integer = 15
Dim j As Integer = 10
Dim k As Integer
Do While j < i
i = i + 1
j += 2
k += i + j
Loop
TextBox1.Text = i
TextBox2.Text = j
TextBox3.Text = k
i | j | k | |
(before loop) | 15 | 10 | 0 |
10<15: T | 16 | 12 | 0+16+12=28 |
12<16: T | 17 | 14 | 28+17+14=59 |
14<17: T | 18 | 16 | 59+18+16=93 |
16<18: T | 19 | 18 | 93+19+18=130 |
18<19: T | 20 | 20 | 130+20+20=170 |
20<20: F |
Output:
20
20
170
Q1:
Dim i As Integer = 6
Dim j As Integer = 8
Dim k As Integer
|
Do
i = i + 1
k += i + j
j += 2
Loop While j < i
TextBox1.Text = k
TextBox2.Text = j
TextBox3.Text = i
i | k | j | |
(before loop) | 6 | 0 | 8 |
7 | 0+7+8=15 | 10 | |
10<7: F |
0 comments:
Post a Comment