Sorts

How would I do this?

Sorted Names
Write a program that prompts the user to enter three names, each no greater than 50 characters, and then displays the names sorted in alphabetical order. Assume that none of the names are the same. For example, if the user entered “Charlie,” “Leslie,” and “Andy,” the program would display: "Andy Charlie Leslie".
Prompts And Output Labels: Each name read should be prompted for by the string "Enter name: ". The names printed out should be separated by at least one space or newline character.
Hello sonia123,

Not a difficult program. So the questions what have you done and what are you having problems with.

First work on getting the user input. I would most likely use a while loop to get the three inputs. I would define a constant at the beginning of main or before main to use in the while condition. This would also bee a good place to check the length of the input fo being no more than 50.

You may want to store the names in an array of strings for later sorting.

Work on one small part at a time. Compile the program and test frequently until it works the way you want before moving on.

Work up some code and post it if you have any problems or post it and I will go over it and help you improve it if necessary.

Hope that helps,

Andy
Topic archived. No new replies allowed.