Programing Exercise: Visual Basic 2008 - Do Loops?

Write a program to display all the numbers between 1 and 100 that are perfect squares. (A

perfect square is an integer that is the square of another integer; 1, 4, 9, and 16 are examples

of perfect squares.)

2 Answers

Relevance
  • Chie
    Lv 5
    1 decade ago
    Favorite Answer

    Does it really have to be a do-while loop?

    Dim num As Integer = 1

    Do While num <= 100

    If Math.Floor(Math.Sqrt(num)) = Math.Sqrt(num) Then Console.WriteLine(num) ' (I'm assuming it'll output to the console)

    num += 1

    Loop

    Here's the for loop (and the easier) version:

    For num As Integer = 1 To 100

    If Math.Floor(Math.Sqrt(num)) = Math.Sqrt(num) Then Console.WriteLine(num)

    Next

  • 4 years ago

    right here is a few psudocode...determine it out from right here Loop by way of all my numbers If quantity is atypical then upload quantity to my comprehensive as quickly as completed looping by way of all numbers exhibit quantity.

Still have questions? Get your answers by asking now.