The purpose of this homework is to give you a chance to focus your knowledge of ABOC Chapter 6 (and similar parts of Chapter 1).
On ALL problems, make appropriate use of const to modify array arguments and create constants for declared array sizes.
For any library you are asked to write, you must write a test driver main to put your library routines through their paces. This can be done with hard-coded tests if the tests are thorough enough (extremely difficult to do!). But it is more properly done with either a series of primed while loops or a menu system. This allows the interactive testing of the system by multiple testers and gives you a higher likely-hood of having thorough tests.
Do problems 6.1-3, 5, and 6 in a single program. Do 6.7-8 together, as well. Make a library for the functions from 6.12-13 (there's a typo in #12 -- a missing x, do you see it?). Make a library for 6.15. Combine 6.20-21 into a single function by passing 'boolean' arguments to tell whether spaces and/or capitalization and/or punctuation should be ignored.
Individually, do 6.4, 9-11, 17-8, 22, 24-8, 31, 33-5, and 38-45. (On 6.38, don't do all twenty-something drawings, just the first 3 and last 3 will do. Why is this an acceptable place to use strlen()?) (On 6.34 make two versions: one that capitalizes only after the -c is seen and another that capitalizes ALL of the arguments.)
In addition, do the following problems:
(I know it seems like a lot of problems, but they are rather simple.)
To hand this in, make sure you script your tests. But avoid scripting a vi session. (You may want to try this to see why I say not to, but make it a short session.) You can avoid this by simply having multiple terminal windows open: script in one and vi in another.
This assignment is (Level 3).
Try to use dynamic memory whenever possible below -- both 1D and 2D.
Add (Level 1) to add problem 6.14 to your library for 6.12-13.
Add (Level 1) to add problem 6.16 to your library for 6.15.
Add (Level 2) to do problem 6.19. See also the online notes about timing.
Add (Level 1.5) to do problem 6.23. Place the printing function, adding function, and your new function in a library. I'll throw in another (Level 0.5) to write an input function (remember the reverse storage!). And another (Level 0.5) to make the output function take a 'width' argument (0 would mean as needed, positives mean right justify in the field, negatives mean left justify in the field), a char argument for the fill character when the width is wider than the number, and a 'boolean' argument to indicate that they want commas inserted in the normal manner. (To make things even, you'll nee to alter the input function -- if you did that option -- to take a 'commas allowed' argument.) And another (Level 0.5) to use a char base type for your 'big number' array. Finally, add another (Level 1.5) to implement a subtraction function. (This will require the ability to handle negative values and will also alter your addition and possibly multiplication routines, too. It will also alter your output and input -- if you did that option -- functions.)
Add (Level 2) to do problem 6.29. You must do both 100 and 200 versions. You should write a 1-2 page summary of your conclusions about your programs' effectiveness. Take grammar as well as vocabulary into account.
Add (Level 2) to do problem 6.30. Fill your translation table (a set of parallel arrays at least 62 elements long) with plain-text:
orig = { 'a', 'b', ... , 'z', 'A', ... , 'Z', '0', ... , '9' } trans = { 'a', 'b', ... , 'z', 'A', ... , 'Z', '0', ... , '9' }
Now ask the user their birthday. Turn their birthday into a single number (somehow). Use this number as the seed for the random number generator you are using (rand(), *rand48(), etc.). Now shuffle the trans array. (To shuffle, swap elements randomly for 'a while'.) Now the user can choose to encode or decode and enter their text. So they can use redirection to still do files, add command-line options for their birthday and whether to encode or decode: -bMM-DD-YY, -e, -d.
(Note that the "Do you know why?" portion would make a good research paper topic, if you were so inclined...)
Add (Level 2) to do problem 6.32. You will get an extra (Level 1) to remove the discussed distortion. Standard terminal screen size is 25x80 (rows by columns). Make your 'plot' 24x79 to avoid edge conditions and give you a line left to prompt for ...er... whatever. Add another (Level 1) to allow the user to enter a set of window bounds like: [0,4,-2,2]. This would indicate that 'x' should range from 0 to 4 and 'y's from -2 to 2 should be displayed.
Add (Level 1.5) to do problem 6.36. Make a nice tabulation of your results.
Add (Level 1.5) to do problem 6.37. Do you need any strcpy's for the swapping? Why not?
Add (Level 1) to do problem 6.46. Could this technology be used to create personalized lisence plates? *grin*