Answer to Question #283492 in Visual Basic for Alvin

Question #283492

Write a statement or a set of statements to accomplish each of the following:

  1. 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.
  2. 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.
  3. Print the even Integers from 1 to 20 using a Do/Loop While structure and the counter variable x. 
1
Expert's answer
2021-12-29T07:57:29-0500
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

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS