Write a For…Next loop that adds the odd numbers 1 through 49 and assigns their sum to the variable intSum. The program should start with the lines shown in Figure 6-113 (use the variables shown in lines 120–123 in your code).

Write a For…Next loop that adds the odd numbers 1 through 49 and assigns their sum to the variable intSum. The program should start with the lines shown in Figure 6-113 (use the variables shown in lines 120–123 in your code).

Answer

👇👇👇👇Click On Below Ads To see The Answer

Code::

Dim intLoopValue As Integer

Dim intStartValue As Integer

Dim intEndvalue As Integer

Dim intSum As Integer

intStartValue = 1

intEndValue = 49

intSum=0

For intLoopValue = intStartValue To intEndValue

If intLoopValue Mod 2 <> 0 Then

''//odd number

''//MsgBox("Odd number: " & intLoopValue )

intSum += intLoopValue

Else

''//even number

End If

Next intLoopValue

MsgBox("total of odd numbers: " & intSum )

Leave a Comment