Using Microsoft Visual Basics (.NET) ONLY! (This assignment encompasses Do-Loop
ID: 3787368 • Letter: U
Question
Using Microsoft Visual Basics (.NET) ONLY!
(This assignment encompasses Do-Loop concepts from Chapter 5. The next assignment will cover For-Next loops and Strings from Chapter 5.)
6. Answer questions (a) through (c) based on code below. (1 point each, 3 total)
Dim num As Integer
Dim sum As Integer
Do
sum = sum + num
num = num + 1
Loop While num < 3
Me.outLabel.Text = sum
Question
Answer
How many times does the body of the loop execute?
What is the output (value assigned to Text property of outLabel)?
What is the final value of num?
7. Answer questions (a) through (c) based on code below. (1 point each, 3 total)
Dim num As Integer = 5 'Note initial value
Dim sum As Integer
Do
sum = sum + num
num = num + 1
Loop While num < 2
Me.outLabel.Text = sum
Question
Answer
How many times does the body of the loop execute?
What is the output (value assigned to Text property of outLabel)?
What is the final value of num?
8. Minimum Loop Execution Count
What is the minimum number of times that the body of a Do … Loop While structure will execute? (1 point)
What is the minimum number of times that the body of a Do While … Loop structure will execute? (1 point)
9. Infinite Loops
What is an infinite loop? (1 point)
What causes an infinite loop? (1 point)
10. Input Box
What is the purpose of an input box? (1 point)
What is the variable type of the return value of an input box? (1 point)
11. Using a Do...Loop While structure, write the code that repeatedly prompts the user using an InputBox for a number, and continues to prompt the user until a valid positive number is entered. (8 points)
12. Determine if each of the following is true or false. (1 point each, 4 total)
Question
True or False
Each execution of a loop is called an iteration.
A Do...Loop body that evaluates the condition after executing the loop may never execute.
Accumulator variables can only be Integer variables.
Sentinel values must always be the value -1 to stop execution.
Question
Answer
How many times does the body of the loop execute?
What is the output (value assigned to Text property of outLabel)?
What is the final value of num?
Explanation / Answer
Hi, I have answerd 6 to 9 questions.
Please repost reaining questions in separate post.
Q6)
How many times does the body of the loop execute? :
Ans: 3 times , for n= 0, 1, 2
What is the output (value assigned to Text property of outLabel)?
Ans: 3
0 + 1 + 2
What is the final value of num?
Ans : 3
Q7)
How many times does the body of the loop execute?
Ans: 1 times, for n = 5
What is the output (value assigned to Text property of outLabel)?
Ans: 5
What is the final value of num?
Ans: 6
8. Minimum Loop Execution Count
What is the minimum number of times that the body of a Do … Loop While structure will execute?
Ans: 1 times
What is the minimum number of times that the body of a Do While … Loop structure will execute?
Ans: 0 times
9. Infinite Loops
What is an infinite loop?
Ans: A loop that never terminats(stops)
What causes an infinite loop? (1 point)
Ans: condition of loop termination never evaluates to true
(or loop entering condition never get evaluated to false)