Write a statement or a set of statements to accomplish each of the following:
Imports System.IO
Module Module1
Sub Main()
Dim sumOddIntegers As Integer = 0
'Sum the odd integers between 25 and 78 using a For/Next structure.
'Assume that variables sum and count have been declared explicitly as Integer.
For count As Integer = 25 To 78
If count Mod 2 = 1 Then
sumOddIntegers += count
End If
Next
Console.WriteLine("Sum the odd integers between 25 and 78: {0}", sumOddIntegers)
'Print the number from 35 to 20 on the form using a Do Until loop and Integer counter variable x.
'Assume that the variable x is initialized to 35.
Dim x As Integer = 35
Console.WriteLine("The number from 35 to 20:")
Do Until x < 20
Console.WriteLine(x.ToString())
x -= 1
Loop
'Print the even Integers from 1 to 20 using a Do/Loop While structure and the counter variable x.
Console.WriteLine("The even Integers from 1 to 20:")
x = 1
Do
If x Mod 2 = 0 Then
Console.WriteLine(x.ToString())
End If
x += 1
Loop While x <= 20
Console.ReadLine()
End Sub
End Module
Comments
Leave a comment