Click to See Complete Forum and Search --> : Programming


winkylocc
January 30th, 2009, 09:15 PM
Hi folks Ed here. I'm new to algorithms and logic and am studying for an assignment in my class which deals with psuedocode mainly. I have run across a while statement that has something in it I can't understand:

While Names [k] <> "*"

I can't figure out what the asterick inside of the quotation marks represents. Can anyone help me with that?

Peter_APIIT
January 31st, 2009, 02:16 AM
"" = String
'' = char

The expression test whether it's a asterisk.

winkylocc
January 31st, 2009, 03:19 PM
OK. So, the expression "*" test whether the inputed Names in the While loop is an asterick? Well I'm going to post the rest of this while loop and ask a question or two.

While Names[k] <>"*"
If Sales[k] > Max Then
Set Index = k
Set Max = Sales[Index]
End If
Set k = k + 1
Write "Enter name and sales (Enter *, 0 when done)"
Input Names[k], Sales[k]
End While

In that statement what confuses me is why we have to set k = k + 1? I'm assuming the k in the brackets is the counter for names and sales input. The index in the bracket next to sales also confuses me. Thanks for the help by the way.

Alsvha
February 2nd, 2009, 05:06 AM
K is just a counter, which is incremented each time you enter a Name/Sale into the function.

It looks like a function where you can continuously enter a Names with a Sale and * to quit (hence the While check, it is the exit command) and then it stores the highest entered sale in the max value and the index of said sale (which is your K counter) in the index.