Posted: Fri Jan 09, 2009 2:39 pm Post subject: Get first name of person- Weird error
Hey im writing a program that a user inputs a list of first names and when they type stop, the names will output in alphabetical order. This is my code
code:
%This program will output last name fist
var firstname:string
var reply:string:=""
loop
put "What is your first name? Type stop to close program!"
get firstname
exit when firstname="stop"
if firstname (1) > reply then
firstname := reply
end if
end loop
put "The alphabetically last name is ", firstname
What is wrong here?
Sponsor Sponsor
Insectoid
Posted: Fri Jan 09, 2009 2:43 pm Post subject: RE:Get first name of person- Weird error
firstname has to be an array of string, and you need a sorting algorithm. Look up bubble sort on wiki.