Section 5.11. Exercises
See Appendix A for answers to the following exercises:
 Write a program that acts like cat but reverses the order of the output lines. (Some systems have a utility like this named tac.) If you run yours as ./tac fred barney betty, the output should be all of file betty from the last line to the first, then barney and then fred, also from the last line to the first. (Be sure to use the ./ in your program's invocation if you call it tac so you don't get the system's utility instead!)
 Write a program that asks the user to enter a list of strings on separate lines, printing each string in a right-justified 20-character column. To be certain that the output is in the proper columns, print a "ruler line" of digits as well. (This is a debugging aid.) Make sure that you're not using a 19-character column by mistake. For example, entering hello, good-bye should give output something like this:
 Modify the previous program to let the user choose the column width, so entering 30, hello, good-bye (on separate lines) would put the strings at the 30th column. (Hint: See the section in Chapter 2 about controlling variable interpolation.) For extra credit, make the ruler line longer when the selected width is larger.
© 2000- NIV