Topical Information

The purpose of this homework is to give you a chance to focus your knowledge of ABOC Chapter 5. (Oddly, there are no similar parts of Chapter 1.)

Homework Information

Do problems 5.2, 3, 6 (again, NOT a typical use of assert), 10-12, 13 (get the start an finish values from your user rather than using #define's), 14 (have your program print the results for numbers the user enters; negative entry ends; print the results in the form the book shows; they mean 'a very fast computer' -- size actually has nothing to do with it), 15, 16 (why does the variable have to be static?), 17, 18 (remove the double return from the recursive version), 20, 21, and 22 (do NOT code like this!).

(Look, the list of problems is getting shorter!)


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).

Options

Add (Level 1) to do problem 5.1. You cannot call any library functions. You need not handle negative powers.

Add another (Level 1) to make your solution to problem 5.1 recursive. Use the idea that:

    x0 = 1
    x1 = x
    xn = x * xn-1

    x2n = xn * xn
To aid you in your quest.

Add (Level 2.5) to do problem 5.7. Since you don't know how to do files yet, you'll have to redirect your output into a file. Rather than change a constant, recompile, and rerun for the different file sizes, use a command line argument (see section 6.14 and strtol on p667-8) to tell your program the number of random values to create.

Add another (Level 2) to make your 5.7 solution actually manipulate the files itself (sections 11.3-5). You'll still use the command line, but now for both the number of values and the file to place those values in. If either/both of these arguments is missing, prompt the user for it/them.

For problem 5.8 you can get the levels listed above for 5.7 if you don't do 5.7. If you do 5.7 and 5.8, then the levels drop by 1 each for 5.8 (5.7's levels are unchanged).

Add (Level 1.5) to do problem 5.23.

Add (Level 3) to do problems 5.24 and 5.25. (Recall that the rand48 family of generators is available on cygwin, linux, and our HP box.)

Add (Level 2) to do problem 5.26. (Yes, use the rand48 generator(s).)

Add (Level 2.5) to do problem 5.27. Don't forget to answer all the questions proposed.