do while loop

program does not give largest number

Page 1 of 1

2 Replies - 8361 Views - Last Post: 17 June 2008 - 09:41 AM Rate Topic: -----

#1 mikeja76  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 17-June 08

do while loop

Post icon  Posted 17 June 2008 - 08:55 AM

I have to write a program that will determine and dispaly the largest number. The user inputs 10 numbers and the program will determine the largest number entered. everything seems to work except that when the loop completes it wont give the largest number. it tells me that it is zero. is there something that i forgot to do? is something inthe wrong spot?? im going crazy trying to figure this out.
any help would be appreciated.

here is what i have for code so far:


Module Largest

Sub Main()

Dim counter As Integer 'used to keep count up to ten
Dim number As Integer 'numbers input by user
Dim largest As Integer 'the largest of the ten numbers
number = largest 'the largest number is also the first initial number

Console.WriteLine("The initial largest number is: " & largest)

'process the 10 numbers

While counter <= 9 'while counter is less than or equal to ten
Console.WriteLine("Enter a Number") 
number = Console.ReadLine() 
counter += 1 'increment the counter
Console.WriteLine("The Count is: " & counter) 
If number > largest Then
number = largest
End If
End While

Console.WriteLine("The largest number of the 10 is:" & largest)

End Sub

End Module



Mod Edit: Please use code tags when posting code => :code:

Is This A Good Question/Topic? 0
  • +

Replies To: do while loop

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9488
  • View blog
  • Posts: 35,792
  • Joined: 12-June 08

Re: do while loop

Posted 17 June 2008 - 08:59 AM

Assignment issue.. largest is supposed to GET the value of number..
largest = number

This post has been edited by PsychoCoder: 17 June 2008 - 09:54 AM

Was This Post Helpful? 0
  • +
  • -

#3 mikeja76  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 17-June 08

Re: do while loop

Posted 17 June 2008 - 09:41 AM

thanks for your help it did work!!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1