Computer Science Using C++

Ch. 10 Exercises Remarks


Exercise 10-1 (p. 186)

Save the program as POINTER.CPP. Notice that the textbook author happens to use "_ptr" to indicate pointer variable names. You may follow his convention for the purposes of typing these chapter exercises. On programming assignments for our class, you should begin pointer variable names with a lower-case 'p'.

Exercise10-2 (p. 187)

Modify POINTER.CPP (from Exercise 10-1). Carefully follow the steps in this exercise and try to understand what is happening "behind the scenes." It is useful to experiment with actual code in order to understand how pointers work. Save the file as POINTER.CPP.

Exercise 10-3 (p. 189)

Save the program as THEPOINT.CPP. This program is efficient because a third variable is not necessary in order to store the current largest number. Since a pointer to a float takes up less memory than an ordinary float variable, memory space is saved by the use of the pointer! In realistic, commercial-size programs this space savings could be significant.

Answer Section 10.1 Questions #1-5 on p. 189 if you have not done so already.

Exercise 10-4 (p. 191)

Save the file as WORDPLAY.CPP. Notice that the 0 index position of a character array is the first letter of the string stored there.

Exercise 10-5 (p. 192)

Save the file as WORDPLAY.CPP. Notice that subscript notation is not the only method which can be used to change one letter of a character array. Which method is easier to understand when reading code, subscript notation or using the dereferencing operator?

Exercise 10-6 (p. 193)

Save the file as ENUMTEST.CPP. Try to printout the value of the enumerated type to see what happens? Read the "Warning" on p. 194, first.

Answer the Section 10.3 Questions #1-5 on p. 195 if you haven't done so already.

Exercise 10-7 (p. 197)

Open STRUCT.CPP from the template directory.

Exercise 10-8 (p. 199)

Save the file as DONORS.CPP.

Exercise 10-9 (p. 200)

Open LNSLOPE.CPP from the template directory.

Answer Section 10.4 Questions on p. 200 if you haven't done so already.

Return to Ch. 10 Resources Page


Computer Science Using C++ Home Page | CMPSC 101 Home Page

Mr. Minich's Wyo Home Page | Mr. Minich's PSU Home Page

Minich.com Web Design