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

Visual studio 2012 multiple choice questions Refer to the code below for questio

ID: 3582589 • Letter: V

Question

Visual studio 2012 multiple choice questions

Refer to the code below for questions on this page.


1.   Dim i, A As Integer
2. Dim FV As Integer = 5
3. Do Until i <= FV
4.       A = i
5.       i = i + 1
6.   Loop

Question 1.1. How many times does this loop run? (Points : 2)        0
       4
       5
       6 Question 2.2. If the terminating condition is changed to i >= FV, how many times does this loop run? (Points : 2)        0
       4
       5
       6 Question 3.3. What is the value of i after the loop terminates? (Points : 2)        0
       4
       5
       6
        Question 4.4. If the loop is changed to Do While 5 <= FV, how many times does this loop run? (Points : 2)        0
       5
       6
       indefinitely

Explanation / Answer

Do Until loop:

Loop gets terminated once the Until condition evaluates to True

Syntax:

   Do Until condition
      
       Statements
      
   Loop

  
Example:
  
   age = 10
  
   Do Until age = 20
        Console.WriteLine(" Age: {0} ", age)
        age = age + 2
   Loop
  
   In this example, variable age is initially initialized to 10.
  
   Do Until loop iterates till the value of age reaches 20. Once the value of the variable age reaches 20, loop gets terminated.
  
  
----------------------------------------------------------------------------------------------------------------

Question 1.1

In the given example, value if i is 0 and value of FV is 5

Until condition i <= FV (0 <= 5) evaluates to True at first iteration itself. Hence the loop runs for 0 number of times.

Hence, Correct answer is 0

----------------------------------------------------------------------------------------------------------------

Question 2.2

If condition is changed to i >= FV

In the given example, value if i is 0 and value of FV is 5

Iteration 1: Until condition i >= FV (0 >= 5) evaluates to False and loop iterates
Iteration 2: Until condition i >= FV (1 >= 5) evaluates to False and loop iterates
Iteration 3: Until condition i >= FV (2 >= 5) evaluates to False and loop iterates
Iteration 4: Until condition i >= FV (3 >= 5) evaluates to False and loop iterates
Iteration 5: Until condition i >= FV (4 >= 5) evaluates to False and loop iterates

Iteration 6: Until condition i >= FV (5 >= 5) evaluates to True and loop stops iteration.

Hence, the loop runs for 5 times.

Hence the correct answer is 5

----------------------------------------------------------------------------------------------------------------

Question 3.3

In the given example, value if i is 0 and value of FV is 5

Until condition i <= FV (0 <= 5) evaluates to True at first iteration itself. Hence the loop runs for 0 number of times.

Value of i is not changed. Hence value of i is still 0 even after loop termination.

Hence the correct answer is 0

----------------------------------------------------------------------------------------------------------------

Question 4.4

Do While loop iterates till the condition evaluates to false.

Initially Value of FV is 5

Condition 5 <= FV evaluates to true and loop gets iterated.

The value of FV is not changed with in the loop. Hence the loop iterates indefinitely

Hence the correct answer is indefinitely