Exercises
What Do Those Numbers Mean at the Start of the Exercise?
Each exercise has a number in square brackets in front of the exercise text, looking
something like this:
1. [6] What does the number 6 inside square brackets mean, when it appears at the
start of an exercise's text?
That number is our (very rough) estimate of how many minutes you can expect to spend on that
particular exercise. It's rough, so don't be too surprised if you're all done (with writing,
testing, and debugging) in half that time, or not done in twice that long. On the other
hand, if you're really stuck, we won't tell anyone that you peeked at
Appendix A, Exercise Answers to see what our answers looked
like.
-
[6] Write a program that reads a list of strings on separate lines until end-of-input
and prints out the list in reverse order. If the input comes from the keyboard, you'll
probably need to signal the end of the input by pressing Control-D on UNIX, or Control-Z on
Windows.
-
[8] Write a program that reads a number and then a list of strings on separate lines
until end_of_input, and then prints one of the lines from the list as selected by the number.
-
[8] Write a program that reads a list of strings (on separate lines) until
end-of-input. Then it should print the strings in ASCIIbetical order. That is, if
you enter the strings fred, barney, wilma, betty, the output should
show barney betty fred wilma. Are all of the strings on one line in the output, or
on separate lines? Could you make the output appear in either style?