# Visual Basic Questions and Answers – Repetition Structure – Do Loop Statement

This set of Visual Basic Multiple Choice Questions & Answers (MCQs) focuses on “Repetition Structure – Do Loop Statement”.

1. Programmers use __________ known as loops.
a) Repetition structure
b) Conditional structure
c) Goto
d) Unconditional structure

Explanation: Programmers use the repetition structure, referred to more simply as a loop, when they need the computer to repeatedly process one or more program instructions. If and for how long the instructions are repeated is determined by the loop’s condition.

2. The requirement for repeating the instructions is referred to as the __________
a) Looping condition
b) Conditional statement
c) Iterative statement
d) Initialization statement

Explanation: The requirement for repeating the instructions is referred to as the looping condition, because it indicates when the computer should continue “looping” through the instructions.

3. The requirement for not repeating the instructions is referred to as the __________
a) Loop exit condition
b) Looping condition
c) Conditional statement
d) Iterative statement

Explanation: The requirement for not repeating the instructions is referred to as the loop exit condition, because it tells the computer when to exit (or stop) the loop. Every looping condition has an opposing loop exit condition; in other words, one is the opposite of the other.

4. In a __________ loop the condition is evaluated before the instructions within the loop are processed.
a) Posttest
b) Pretest
c) Conditional loop
d) Unconditional loop

Explanation: In a pretest loop, the condition is evaluated before the instructions within the loop are processed. For example,

```repeat while balance &lt; 250,000
interest = balance * rate
add 1 to number of years
end repeat while```

5. In a __________ loop the condition is evaluated before the instructions within the loop are processed.
a) Posttest
b) Pretest
c) Conditional loop
d) Unconditional loop

Explanation: In a posttest loop, the condition is evaluated after the instructions within the loop are processed. For example,

Note: Join free Sanfoundry classes at Telegram or Youtube
```repeat
interest = balance * rate
add 1 to number of years
end repeat while balance &lt; 250,000```

6. The __________ is used to code both pretest and posttest loops.
a) Do loop statement
b) For loop statement
c) While loop statement
d) If statement

Explanation: The do..loop statement is used to code both pretest and posttest loops. For example,
Pretest:

```Do {While | Until} condition
loop body instructions, which will be processed either
while the condition is true or until the condition becomes true
Loop```

Posttest:

```Do
loop body instructions, which will be processed either
while the condition is true or until the condition becomes true
Loop {While | Until} condition```

7. The __________ in a Do…Loop statement can contain variables, methods, constants, properties and operators.
a) Exit statement
b) Condition
c) Statement
d) Iteration statement

Explanation: The condition in a Do . . . Loop statement can contain variables, constants, properties, methods, keywords, and operators; it also must evaluate to a Boolean value. The condition is evaluated with each repetition of the loop and determines whether the computer processes the loop body.

8. How many times will the MessageBox.Show method in the following code be processed?

```intCount =0
Do While intCount > 3
MessageBox.Show("Hello")
intCount = intCount + 1
Loop```

a) 0
b) 1
c) 3
d) 4

Explanation: Since intCount is initialized to zero, the condition in the Do while statement will be false, and since the body of the loop will be executed, only if the condition is true, thus it will not be executed even once. Thus Messagebox.Show method will not be processed even once.

9. How many times will the MessageBox.Show method in the following code be processed?

```intCount =0;
Do
MessageBox.Show("Hello")
intCount += 1
Loop While intCount > 3```

a) 0
b) 1
c) 3
d) 4

Explanation: Since it is posttest, thus the body of the loop will be executed at least once, even if the condition is false. Thus, here since the condition is false, the body of the loop will be executed once, and thus MessageBox.Show will be processed only once.

10. The instructions in a __________ loop are always processed at least once, whereas the instructions in a __________ loop might not be processed at all.
a) Posttest, pretest
b) Pretest, posttest
c) Pretest, pretest
d) Posttest, posttest

Explanation: The instructions in a posttest loop are always processed at least one, since the condition is checked after the loop body is executed at least one. So even if the condition is false, the loop body is executed at least once. Whereas the instructions in a pretest loop is not processed if the condition is false, since the condition is checked before the body of the loop is executed.

Sanfoundry Global Education & Learning Series – Visual Basic.

To practice all areas of Visual Basic, here is complete set of 1000+ Multiple Choice Questions and Answers.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]