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