Using Microsoft Visual Basics NET ONLY This assignment encom

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.)

1. What is the primary purpose of a loop? (2 points)

2. Answer questions (a) through (e) based on code below. (1 point each, 5 total)

Dim num As Integer

Dim sum As Integer

Do While num < 3

   sum = sum + num

   num = num + 1

Loop

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?

What is the counter variable?

What is the accumulator variable?

3. Answer questions (a) through (c) based on code below. (1 point each, 3 total)

Dim num As Integer

Dim sum As Integer

Do While num <= 3

   sum = sum + num

   num = num + 1

Loop

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?

4. Answer questions (a) through (c) based on code below. (1 point each, 3 total)

Dim num As Integer = 2 \'Note initial value

Dim sum As Integer

Do While num < 2

   sum = sum + num

   num = num + 1

Loop

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?

5. Answer questions (a) through (c) based on code below. (1 point each, 3 total)

Dim num As Integer

Dim counter As Integer

Dim sum As Integer

Do While num < 3

   sum = sum + num

   counter = counter + 1

Loop

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?

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?

What is the counter variable?

What is the accumulator variable?

Solution

1. A loop is used to repeat a set of instructions until a condition is reached. it can be without any condition also which is infinite loop.

2.

a. 3(num=0,1,2)

b.sum = 0+1+2 = 3

c. num =2

d. counter = num

e. accumulator = sum

3.

a. 4(num =0,1,2,3)

b. sum = 6(0+1+2+3)

c. 3

4.

a. 0 times(while loop condition is false)

b. sum = 0

c. num = 2(initial value)

5.

a. infinite loop as num is not incremented

b. sum = 0

c. num = 0

Using Microsoft Visual Basics (.NET) ONLY! (This assignment encompasses Do-Loop concepts from Chapter 5. The next assignment will cover For-Next loops and Strin
Using Microsoft Visual Basics (.NET) ONLY! (This assignment encompasses Do-Loop concepts from Chapter 5. The next assignment will cover For-Next loops and Strin
Using Microsoft Visual Basics (.NET) ONLY! (This assignment encompasses Do-Loop concepts from Chapter 5. The next assignment will cover For-Next loops and Strin

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site