Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. What is wrong with the following Do While loop? Dim index As Integer = 1 Do W

ID: 638340 • Letter: 1

Question

1.      What is wrong with the following Do While loop?

Dim index As Integer = 1

Do While index <> 9

lstBox.Items.Add("Hello")

index += 1

Loop

a.   The test variable should not be changed inside a Do loop.

b.   The test condition will never be true.

c.   This is an infinite loop.

d.   Nothing

2.      In analyzing the solution to a program, you conclude that you want to construct a loop so that the loop terminates either when (a < 12) or when (b = 16). Using a Do loop, the test condition should be:

a.   Do While (a > 12) Or (b < > 16)

b.   Do While (a >= 12) Or (b < > 16)

c.   Do While (a < 12) Or (b < > 16)

d.   Do While (a >= 12) And (b < > 16)

3.      When Visual Basic

Explanation / Answer

Answers:

1) d.   Nothing

2) d.   Do While (a >= 12) And (b < > 16)

3) c.   condition

4) b.   pon

5) c.   A division by zero error could occur when computing the average.

6) c.   It will display