Do Loop Exercises

1) For the following code
    a. How many numbers will be displayed?
    b. What will the first number printed be?
    c. What will be the last number displayed?

Dim intNum As Integer
 
intNum = 0
 
Do While intNum <= 20
        intNum += 1
        MsgBox(intNum)
Loop

 

2) What will be the output from the following?

Dim decBalance As Decimal
Dim
decAPR As Decimal
Dim
decTargetAmount As Decimal
Dim
intYears As Integer
 
decBalance = 1000
decAPR = .10
decTargetAmount = 1500
intYears = 0
 
Do
        decBalance = decBalance + (decBalance   * decAPR)
        intYears += 1
Loop Until decBalance >= decTargetAmount
 
Msgbox(“Balance = “ & decBalance & “ after “ & intYears)