u u u
SOLUTIONS
,Contents
1 About This Solutions Manual
u u u 1
1.1 To the Student . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
u u u u u u u u u u u u u u u u u u u u u u u u u u u u u u u u u u 1
1.2 To the Instructor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
u u u u u u u u u u u u u u u u u u u u u u u u u u u u u u u u u u u 1
2 Solutions to the Exercises u u u 3
Chapter 1 u . u . u .
u . u . u .
u .
u .
u . u . u .
u .
u .
u . u .
u .
u .
u . u . u . u . u .
u .
u .
u . u .
u .
u .
u . u . u .
u .
u . u . u . u .
u . u . u . 5
Chapter 2 u . u . u .
u . u . u .
u .
u .
u . u . u .
u .
u .
u . u .
u .
u .
u . u . u . u . u .
u .
u .
u . u .
u .
u .
u . u . u .
u .
u . u . u . u .
u . u . u . 9
Chapter 3 u . u . u .
u . u . u .
u .
u .
u . u . u .
u .
u .
u . u .
u .
u .
u . u . u . u . u .
u .
u .
u . u .
u .
u .
u . u . u .
u .
u . u . u . u .
u . u . u . 17
Chapter 4 u . u . u .
u . u . u .
u .
u .
u . u . u .
u .
u .
u . u .
u .
u .
u . u . u . u . u .
u .
u .
u . u .
u .
u .
u . u . u .
u .
u . u . u . u .
u . u . u . 33
Chapter 5 u . u . u .
u . u . u .
u .
u .
u . u . u .
u .
u .
u . u .
u .
u .
u . u . u . u . u .
u .
u .
u . u .
u .
u .
u . u . u .
u .
u . u . u . u .
u . u . u . 75
Chapter 6 u . u . u .
u . u . u .
u .
u .
u . u . u .
u .
u .
u . u .
u .
u .
u . u . u . u . u .
u .
u .
u . u .
u .
u .
u . u . u .
u .
u . u . u . u .
u . u . u . 95
Chapter 7 u . u . u .
u . u . u .
u .
u .
u . u . u .
u .
u .
u . u .
u .
u .
u . u . u . u . u .
u .
u .
u . u .
u .
u .
u . u . u .
u .
u . u . u . u .
u . u . u . 115
Chapter 8 u . u . u .
u . u . u .
u .
u .
u . u . u .
u .
u .
u . u .
u .
u .
u . u . u . u . u .
u .
u .
u . u .
u .
u .
u . u . u .
u .
u . u . u . u .
u . u . u . 121
Chapter 9 u . u . u .
u . u . u .
u .
u .
u . u . u .
u .
u .
u . u .
u .
u .
u . u . u . u . u .
u .
u .
u . u .
u .
u .
u . u . u .
u .
u . u . u . u .
u . u . u . 129
Chapter 10 u . u . u .
u . u . u .
u .
u .
u . u . u .
u .
u .
u . u .
u .
u .
u . u . u . u . u .
u .
u .
u . u .
u .
u .
u . u . u .
u .
u . u . u . u .
u . u . u . 139
Chapter 11 u . u . u .
u . u . u .
u .
u .
u . u . u .
u .
u .
u . u .
u .
u .
u . u . u . u . u .
u .
u .
u . u .
u .
u .
u . u . u .
u .
u . u . u . u .
u . u . u . 159
Chapter 12 u . u . u .
u . u . u .
u .
u .
u . u . u .
u .
u .
u . u .
u .
u .
u . u . u . u . u .
u .
u .
u . u .
u .
u .
u . u . u .
u .
u . u . u . u .
u . u . u . 171
Chapter 13 u . u . u .
u . u . u .
u .
u .
u . u . u .
u .
u .
u . u .
u .
u .
u . u . u . u . u .
u .
u .
u . u .
u .
u .
u . u . u .
u .
u . u . u . u .
u . u . u . 179
Chapter 14 u . u . u .
u . u . u .
u .
u .
u . u . u .
u .
u .
u . u .
u .
u .
u . u . u . u . u .
u .
u .
u . u .
u .
u .
u . u . u .
u .
u . u . u . u .
u . u . u . 189
Chapter 15 u . u . u .
u . u . u .
u .
u .
u . u . u .
u .
u .
u . u .
u .
u .
u . u . u . u . u .
u .
u .
u . u .
u .
u .
u . u . u .
u .
u . u . u . u .
u . u . u . 195
Chapter 16 u . u . u .
u . u . u .
u .
u .
u . u . u .
u .
u .
u . u .
u .
u .
u . u . u . u . u .
u .
u .
u . u .
u .
u .
u . u . u .
u .
u . u . u . u .
u . u . u . 201
Chapter 17 u . u . u .
u . u . u .
u .
u .
u . u . u .
u .
u .
u . u .
u .
u .
u . u . u . u . u .
u .
u .
u . u .
u .
u .
u . u . u .
u .
u . u . u . u .
u . u . u . 207
3 Extra Exercises and Their Solutions
u u u u 221
4 Teaching FORTRAN Programming
u u 259
v
,1
About This Solutions Manual u u u
1.1 To the Student u u
This Solutions Manual is intended for the instructor of a course that uses Classical FORTRAN
u u u u u u u u u u u u u u
as a textbook, and for the student who is learning the subject independently.
u u u u u u u u u u u u
If you are a student taking the course for credit you should know that it is a violation of academic
u u u u u u u u u u u u u u u u u u u u
ethics for you to consult this Solutions Manual, whether you copy verbatim from it or only use it to ge
u u u u u u u u u u u u u u u u u u u
t ideas about how to work the exercises. The exercises are a valuable aid to learning the material in t
u u u u u u u u u u u u u u u u u u u
he textbook, but only if you work them yourself ! Looking up the answers instead of figuring them ou
u u u u u u u u u u u u u u u u u u
t deprives you of an opportunity to learn the material. If an answer is for credit, cheating is also pers
u u u u u u u u u u u u u u u u u u u
onally degrading to you and unfair to your classmates, and it might place you in jeopardy of discipl
u u u u u u u u u u u u u u u u u
inary action. If this is an illicit copy, please destroy it now. If this is a stolen copy, please return it to it
u u u u u u u u u u u u u u u u u u u u u u
s rightful owner. Either way, STOP READING.
u u u u u u
If you are a student learning the subject by yourself then you are your own instruc-
u u u u u u u u u u u u u u u
tor. Please read the next section.
u u u u u
1.2 To the Instructor u u
This Solutions Manual is intended for the instructor of a course that uses Classical FORTRAN
u u u u u u u u u u u u u u
as a textbook, and for the student who is learning the subject independently.
u u u u u u u u u u u u
If you are in either category you should know that it greatly diminishes the usefulness of the exerc
u u u u u u u u u u u u u u u u u
ises for graded work if their solutions become public. Please refrain from loaning this book to others
u u u u u u u u u u u u u u u u
, distributing solutions to others, or posting solutions on the World Wide Web. If you want to show a
u u u u u u u u u u u u u u u u u u
ugroup how to solve a problem, I suggest making a transparency or scanning to a .pdf file for proje
u u u u u u u u u u u u u u u u u u
ction, or posting the solution in a display case under glass, so as to reveal the answer while discou
u u u u u u u u u u u u u u u u u u
raging photocopying or electronic scanning.
u u u u
At the same time, it is prudent for instructors to expect that some students will have access to the
u u u u u u u u u u u u u u u u u u u
solutions and thus an unfair advantage over their classmates who do not. If you suspect this might b
u u u u u u u u u u u u u u u u u
e the case, you should consider assigning textbook exercises whose solutions are not included in this
u u u u u u u u u u u u u u u
uManual or making up problems of your own, perhaps modeled on exercises in the textbook.
u u u u u u u u u u u u u u
Chapter 2 of this Manual provides solutions to about half of the exercises in the text, distributed in
u u u u u u u u u u u u u u u u u u
such a way as to represent each problem type in each chapter while favoring easy problems and earl
u u u u u u u u u u u u u u u u u
y chapters. Chapter 3 of this Manual contains some additional exercises and their solutions. Chapte
u u u u u u u u u u u u u u
r 4 contains some materials that I have found useful in teaching programming from Classical FORT
u u u u u u u u u u u u u u u
RAN.
1
, 2
Solutions to the Exercises u u u
Each solution includes my rough estimate of how difficult the exercise is. Easy problems, marke
u u u u u u u u u u u u u u
d [E], test the student’s recall of facts and concepts discussed in the text. Hard problems, ma
u u u u u u u u u u u u u u u u
rked [H], need some independent thought and possibly some programming but usually do not ex
u u u u u u u u u u u u u u
plicitly require the student to deliver a program. Projects, marked [P], typically ask for a finished
u u u u u u u u u u u u u u u u
program as part of the solution to the exercise, and in most cases providing one requires analysis,
u u u u u u u u u u u u u u u u u
program design, and debugging as well as coding in FORTRAN. The fraction of solutions presented her
u u u u u u u u u u u u u u u
e varies from one part of the textbook to another and by problem difficulty, according to the table b
u u u u u u u u u u u u u u u u u u
elow.
part (see §0.5.3) u u [E] easy u [H] hard u [P] project u
INSPIRATION none none none
1 1
ELEMENTARY all
2 3
1 1 1
INTERMEDIATE
2 3 4
1 1 1
ADVANCED
3 4 5
REFERENCE none none none
The parts of the book that are listed in the left column are those identified in the table of
u u u u u u u u u u u u u u u u u u
§0.5.3 in the text. The actual number of solutions provided for each chapter and difficulty level is
u u u u u u u u u u u u u u u u u
⌈ ×n is⌉ the number of problems having that difficulty in the chapter and f is the fractio
n f , where
u u u
u u
u u
u u
u u u u u u u u u u u u u u u
n solved of that difficulty in the part of the book to which the chapter belongs. Applying the form
u u u u u u u u u u u u u u u u u u
ula yields the distribution of solutions shown in the table on the next page.
u u u u u u u u u u u u u
Many of the solutions provide a more thorough discussion of the problem than one might expect f
u u u u u u u u u u u u u u u u
rom a student, a few refer incidentally to text sections that the student need not have read yet, and so
u u u u u u u u u u u u u u u u u u u
me of the projects are sufficiently open-
u u u u u u
ended that many different “answers” could be considered correct. Thus, these solutions are meant t
u u u u u u u u u u u u u u
o enlighten the grader rather than to serve as strict templates against which student work is directly
u u u u u u u u u u u u u u u u u
compared.
Because each solution is self- u u u u
contained, literature citations in this Manual are given within each solution rather than being collecte
u u u u u u u u u u u u u u
d in a bibliography. Section references appearing in the solutions are to sections in the textbook,
u u u u u u u u u u u u u u u
unot to sections of this Manual. Output formatting in the terminal session excerpts varies slightly dep
u u u u u u u u u u u u u u u
ending on the UNIXTM system (Sun, IBM, SGI, or Linux) that I used to run each program.
u u u u u u u u u u u u u u u u
If you need a solution that was not selected for inclusion here, please contact the author by sen
u u u u u u u u u u u u u u u u u
ding email to or paper mail to PO Box 215, Cropseyville, NY 12052.
u u u u u u u u u u u u u
3
@@SSee
isis
mmiciicsis
oolala
titoionn