Tải bản đầy đủ (.pdf) (730 trang)

Programming in c++ for engineering and science (1)

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (20.92 MB, 730 trang )

C++

for Engineering and Science
Developed from the author’s many years of teaching computing courses, Programming in C++
for Engineering and Science guides readers in designing programs to solve real problems
encountered in engineering and scientific applications. These problems include radioactive
decay, pollution indexes, digital circuits, differential equations, Internet addresses, data analysis,
simulation, quality control, electrical networks, data encryption, beam deflection, and many other
areas.

Nyhoff

Features
• Uses standard C++ throughout
• Explains key concepts, such as functions and classes, through a “use it first, build it later”
approach
• Shows how to develop programs to solve real problems, emphasizing the proper techniques
of design and style
• Introduces the very powerful and useful Standard Template Library along with important
class and function templates
• Develops numeric techniques and programs for some engineering and science example
problems
• Highlights key terms, important points, design and style suggestions, and common
programming pitfalls in the chapter summaries
• Includes self-study questions and programming projects in each chapter
• Provides ancillary materials on the book’s website

Programming
in

C++



for Engineering
and Science

C++

To make it easier for novices to develop programs, the author uses an object-centered design
approach that helps readers identify the objects in a problem and the operations needed; develop
an algorithm for processing; implement the objects, operations, and algorithm in a program;
and test, correct, and revise the program. He also revisits topics in greater detail as the text
progresses. By the end of the book, readers will have a solid understanding of how C++ can be
used to process complex objects, including how classes can be built to model objects.

Programming in

Programming in

for Engineering and Science

Computer Science

Larry Nyhoff

K11207

K11207_Cover.indd 1

6/19/12 9:01 AM



Programming in

C++

for Engineering and Science

K11207.indb 1

6/15/12 10:06 AM


This page intentionally left blank


Programming in

C++

for Engineering and Science

Larry Nyhoff

K11207.indb 3

6/15/12 10:06 AM


CRC Press
Taylor & Francis Group
6000 Broken Sound Parkway NW, Suite 300

Boca Raton, FL 33487-2742
© 2012 by Taylor & Francis Group, LLC
CRC Press is an imprint of Taylor & Francis Group, an Informa business
No claim to original U.S. Government works
Version Date: 20120409
International Standard Book Number-13: 978-1-4398-2535-8 (eBook - PDF)
This book contains information obtained from authentic and highly regarded sources. Reasonable efforts have been made to
publish reliable data and information, but the author and publisher cannot assume responsibility for the validity of all materials
or the consequences of their use. The authors and publishers have attempted to trace the copyright holders of all material reproduced in this publication and apologize to copyright holders if permission to publish in this form has not been obtained. If any
copyright material has not been acknowledged please write and let us know so we may rectify in any future reprint.
Except as permitted under U.S. Copyright Law, no part of this book may be reprinted, reproduced, transmitted, or utilized in any
form by any electronic, mechanical, or other means, now known or hereafter invented, including photocopying, microfilming,
and recording, or in any information storage or retrieval system, without written permission from the publishers.
For permission to photocopy or use material electronically from this work, please access www.copyright.com ( or contact the Copyright Clearance Center, Inc. (CCC), 222 Rosewood Drive, Danvers, MA 01923, 978-750-8400.
CCC is a not-for-profit organization that provides licenses and registration for a variety of users. For organizations that have been
granted a photocopy license by the CCC, a separate system of payment has been arranged.
Trademark Notice: Product or corporate names may be trademarks or registered trademarks, and are used only for identification and explanation without intent to infringe.
Visit the Taylor & Francis Web site at

and the CRC Press Web site at



Contents
Preface, vii
Acknowledgments, xi
About the Author, xiii
Chapter 1 ■ Introduction to Computing

1


Chapter 2 ■ Programming and Problem Solving—
Software Engineering

21

Chapter 3 ■ Types in C++

39

Chapter 4 ■ Getting Started with Expressions

63

Chapter 5 ■ Control Structures

107

Chapter 6 ■ Functions and Libraries

149

Chapter 7 ■ Using Classes

207

Chapter 8 ■ More Selection Control Structures

261


Chapter 9 ■ More Repetition Control Structures

295

Chapter 10 ■ Functions in Depth

351

Chapter 11 ■ Files and Streams

409

Chapter 12 ■ Arrays and the vector Class Template

451

Chapter 13 ■ Multidimensional Arrays and Vectors

503

v


vi    ◾    Contents

Chapter 14 ■ Building Classes

553

Chapter 15 ■ Pointers and Linked Structures


593

Chapter 16 ■ Data Structures

637

Answers to Test Yourself Questions, 677
Appendix A: ASCII Character Codes, 693
Appendix B: C++ Keywords, 697
Appendix C: C++ Operators, 699
Appendix D: Other C++ Features, 701
Index, 715

K11207.indb 6

6/15/12 10:06 AM


Preface

C

++ is a general-purpose programming language that has both high-level and low-level language features. Bjarne Stroustrup developed it in 1979
at Bell Labs as a series of enhancements to the C programming language, which, although developed for
system programming, has been used increasingly in
engineering and scientific applications.
Because the first enhancement was the addition of
classes, the resulting language was originally named
Bjarne Stroustrup

“C with Classes,” but was renamed C++ in 1983.
Along with overcoming some of the dangers and disadvantages of C, these and subsequent
enhancements have resulted in a very powerful language in which very efficient programs
can be written and developed using the object-oriented paradigm. A programming language standard for C++ (ISO/IEC148821998) was adopted in 1998 and revised in 2003 and
is the basis for this text.

Background and Content
This text grew out of many years of teaching courses in computing, including programming courses intended for students majoring in engineering and science. Although the
Fortran language was first used, these courses are now taught using C++. However, most
C++ textbooks are written for the general college student and thus include examples and
some content that is not aimed at or especially relevant to science and engineering students.
In this text, nearly all of the examples and exercises involve engineering and scientific
applications, including the following (and many more):
• Temperature conversion
• Radioactive decay
• Einstein’s equation
• Pollution indexes
• Digital circuits
• Root finding, integration, differential equations
vii


viii    ◾    Preface

• Internet addresses
• A-C circuits
• Simulation
• Quality control
• Street networks
• Environmental data analysis

• Searching a chemistry database
• Oceanographic data analysis
• Electrical networks
• Coordinate transformations
• Data encryption
• Beam deflection
• Weather data analysis
• Oceanographic data analysis
Some examples are described and solved in detail, while for others the presentation in the
text outlines the solution and the complete development is available on the text’s website
maintained by the author:
/>This text also focuses on those features of C++ that are most important in engineering
and science applications, with other features described in optional sections, appendices, or
on the text’s website. This makes it useable in a variety of courses ranging from a regular
full-credit course to one with reduced credit such as a two-credit course that the author has
taught many times, where the class lectures are supplemented by lab exercises—tutorial in
nature—in which the students develop a program to solve some problem using the new
language features presented in class.

Presentation
The basic approach of the text is a spiral approach that revisits topics in increasingly more
detail. For example, the basic C++ operations used to build expressions are presented first,
and then predefined functions provided in C++ libraries are added. Once students have
experience with functions, they learn how to define their own simple functions and then
more complicated ones. Later they learn how to incorporate these into libraries of their
own, thus extending the C++ language with custom-designed libraries.

K11207.indb 8

6/15/12 10:06 AM



Preface    ◾    ix

Learning how to develop a program from scratch, however, can be a difficult and challenging task for novice programmers. A methodology used in this text for designing
programs to solve problems, developed over years of teaching C++ to computer science,
engineering, and science students and coauthoring texts in C++, is called object-centered
design (OCD):
• Identify the objects in the problem that need to be processed.
• Identify the operations needed to do this processing.
• Develop an algorithm for this processing.
• Implement these objects, operations, and algorithm in a program.
• Test, correct, and revise the program.
Although this approach cannot technically be called object-oriented design (OOD), it does
focus on the objects and operations on these objects in a problem. As new language constructs are learned, they are incorporated into the design process. For example, simple
types of objects are used in early chapters, but Chapter 7 introduces students to some of the
standard classes provided in C++ for processing more complex objects—those that have
multiple attributes. In subsequent chapters, more classes are introduced and explained,
and students gain more practice in using them and understanding the structure of a class.
Once they have a good understanding of these predefined standard classes, in Chapter 14
they learn how to build their own classes to model objects, thus extending the C++ language to include a new custom-built type.

Important Features
• Standard C++ is used throughout.
• A “use it first—build it later” approach is used for key concepts such as functions (use
predefined functions first, build functions later) and classes (use predefined classes
first, build classes later). Various other topics are similarly introduced early and used,
and are expanded later—a spiral kind of approach.
• The very powerful and useful Standard Template Library (STL) is introduced and
some of the important class templates (e.g., vector) and function templates (e.g.,

sort()) are presented in detail.
• C++’s language features that are not provided in C are noted.
• Engineering and science examples, including numeric techniques, are emphasized.
• Programs for some examples are developed in detail; for others, the design of a program is outlined and a complete development is available on the text’s website.
• Object-centered design (OCD) helps students develop programs to solve problems.
• Proper techniques of design and style are emphasized and used throughout.

K11207.indb 9

6/15/12 10:06 AM


x    ◾    Preface

• Test-yourself questions (with answers supplied) provide a quick check of understanding of the material being studied.
• Chapter summaries highlight key terms, important points, design and style suggestions, and common programming pitfalls.
• Each chapter has a carefully selected set of programming projects of varying degrees
of difficulty that make use of the topics presented in that chapter. Solutions of
selected projects are available on an instructor’s website and can be used for in-class
presentations.

Planned Supplementary Materials
• A lab manual (perhaps online) containing laboratory exercises and projects coordinated
with the text
• A website ( for the text containing
• Source code for the programs in the text
• Expanded presentations and source code for some examples
• Links to important sites that correspond to items in the text
• Corrections, additions, reference materials, and other supplementary materials
• A website for instructors containing

• PowerPoint slides to use in class presentations
• Solutions to exercises
• Other instructional materials and links to relevant items of interest

K11207.indb 10

6/15/12 10:06 AM


Acknowledgments

I

express my special appreciation to Alan Apt, whose friendship extends over many
years and who encouraged me to write this text; to Randi Cohen, David Tumarkin,
Suzanne Lassandro, and Jennifer Ahringer, who managed all the details involved in getting
it into production; and to Yong Bakos, for his technical review of the manuscript. And,
of course, I pay homage to my wife, Shar, and to our children and grandchildren—Jeff,
Rebecca, Megan, and Sara; Jim; Greg, Julie, Joshua, Derek, and Isabelle; Tom, Joan, Abigail,
Micah, Lucas, Gabriel, Eden, and Josiah—for their love and understanding when my
busyness restricted the time I could spend with them. Above all, I give thanks to God for
the opportunity and ability to prepare this text.

xi


This page intentionally left blank


About the Author


A

fter graduating from Calvin College in 1960 with a degree in mathematics,
Larry Nyhoff went on to earn a master’s degree in mathematics from the University
of Michigan in 1961, and then returned to Calvin in 1963 to teach. After earning his PhD
from Michigan State University in 1969, he settled in for an anticipated lifelong career as a
mathematics professor and coauthored his first textbook, Essentials of College Mathematics
(Holt, Rinehart, Winston, Inc.), in 1969.
However, as students began clamoring for computing courses in the ‘70s, Professor
Nyhoff volunteered to help develop a curriculum and coauthored several manuals for the
BASIC, FORTRAN, and COBOL programming languages. Following graduate work in
computer science at Western Michigan University from 1981–1983, he made the transition
from mathematics to computing and became a professor in the newly formed Computer
Science Department.
A long stint of textbook writing soon commenced, beginning with a coauthored
FORTRAN 77 programming text that was published by Macmillan in 1983. This was
then followed by a Pascal programming text, which went through three editions and
became a top seller. Over 25 other books followed, covering FORTRAN 90, Turbo Pascal,
Modula-2, and Java, and including three editions of a very popular C++ text and an
introductory text in data structures using C++. Several of these texts are still used worldwide and some have been translated into other languages, including Spanish, Chinese,
and Greek.
A year before his retirement in 2003, after 41 years of full-time teaching, Professor
Nyhoff was awarded the Presidential Award for Exemplary Teaching, Calvin College’s
highest faculty honor. Since retirement, he has continued instructing part-time, teaching
sections of “Applied C++,” a two-credit course required of all engineering students and
also taken by several science students. This textbook is the result of preliminary versions
used in that course over several semesters.

xiii



This page intentionally left blank


Chapter

1

Introduction to Computing

Contents
1.1 Computing Systems
2
1.2 Computer Organization
14
Exercises20
I wish these calculations had been executed by steam.
Charles Babbage
One machine can do the work of fifty ordinary men. No machine can do the work
of one extraordinary man.
Elbert Hubbard
Where a computer like the ENIAC is equipped with 18,000 vacuum tubes and
weighs 30 tons, computers in the future may have only 1000 vacuum tubes and
weigh only 1-1/2 tons.
Popular Mechanics (March 1949)
640K ought to be enough for anyone.
Bill Gates (1981)
So IBM has equipped all XTs with what it considers to be the minimum gear for a
serious personal computer. Now the 10-megabyte disk and the 128K of memory are

naturals for a serious machine.
Peter Norton (1983)

1


2    ◾    Programming in C++ for Engineering and Science

T

he modern electronic computer is one of the most important products of the twentieth century. It is an essential tool in many areas, including business, industry, government, science, and education; indeed, it has touched nearly every aspect of our lives. The
impact of the twentieth-century information revolution brought about by the development of
high-speed computing systems has been nearly as widespread as the impact of the nineteenthcentury industrial revolution. In this chapter we begin with some background by describing
computing systems, their main components, and how information is stored in them.
Early computers were very difficult to program. In fact, programming some of the earliest computers consisted of designing and building circuits to carry out the computations
required to solve each new problem. Later, computer instructions could be coded in a language that the machine could understand. But these codes were very cryptic, and programming was therefore very tedious and error prone. Computers would not have gained
widespread use if it had not been for the development of high-level programming languages that made it possible to enter instructions using an English-like syntax.
Fortran, C, C++, Java, and Python are some of the languages that are used extensively in
engineering and scientific applications. This text will focus on C++ but will also describe
some properties of its parent language, C, noting features that these two languages have in
common, as well as their differences.

1.1  Computing Systems
Four important concepts have shaped the history of computing:
1.The mechanization of arithmetic
2.The stored program
3.The graphical user interface
4.The computer network
This section briefly describes a few of the important events and devices that have implemented these concepts. Additional information can be found on the website for this book
described in the preface.

1.1.1  Machines to Do Arithmetic
One of the earliest “personal calculators” was the abacus (Figure 1.1a), with movable beads
strung on rods to count and to do calculations. Although its exact origin is unknown, the
abacus was used by the Chinese perhaps 3000 to 4000 years ago and is still used today
throughout Asia. Early merchants used the abacus in trading transactions. The ancient
British stone monument Stonehenge (Figure  1.1b), located near Salisbury, England, was
built between 1900 and 1600 BC and, evidently, was used to predict the changes of the
seasons. In the twelfth century, a Persian teacher of mathematics in Baghdad, Muhammad
ibn-Musa al-Khowarizm, developed some of the first step-by-step procedures for doing
computations. The word algorithm, used for such procedures, is derived from his name.

K11207.indb 2

6/15/12 10:06 AM


Introduction to Computing    ◾    3  

(a)

(b)

(c)

Figure 1.1  (a) Abacus. (Image courtesy of the Computer History Museum.) (b) Stonehenge.

(c) Slide rule.

K11207.indb 3


6/15/12 10:06 AM


4    ◾    Programming in C++ for Engineering and Science

The English mathematician William Oughtred invented a circular slide rule in the early
1600s, and more modern ones (Figure 1.1c) were used by engineers and scientists through
the 1950s and into the 1960s to do rapid approximate computations.
In 1642, the young French mathematician Blaise Pascal invented one of the first mechanical adding machines to help his father with calculating taxes. This Pascaline (Figure 1.2a)
was a digital calculator because it represented numerical information as discrete digits, as
opposed to a graduated scale like that used in analog instruments of measurement such
as slide rules and nondigital thermometers. Each digit was represented by a gear that
had 10 different positions (a ten-state device) so that it could “count” from 0 through 9
and, upon reaching 10, would reset to 0 and advance the gear in the next column so as to
represent the action of “carrying” to the next digit. In 1673, the German mathematician
Gottfried Wilhelm von Leibniz invented an improved mechanical calculator (Figure 1.2b)
that also used a system of gears and dials to do calculations. However, it was more reliable
and accurate than the Pascaline and could perform all four of the basic arithmetic operations of addition, subtraction, multiplication, and division. A number of other mechanical
­calculators followed that further refined Pascal’s and Leibniz’s designs, and by the end of
the nineteenth century, these calculators had become important tools in science, business,
and commerce.
1.1.2  The Stored Program Concept
The fundamental idea that distinguishes computers from calculators is the concept of a
stored program that controls the computation. A program is a sequence of instructions
that the computer follows to solve some problem. An income tax form is a good analogy.
Although a calculator can be a useful tool in the process, computing taxes involves much
more than arithmetic. To produce the correct result, one must execute the form’s precise
sequence of steps of writing numbers down (storage), looking numbers up (retrieval), and
computation to produce the correct result.
The stored program concept also gives the computer its amazing versatility. Unlike most

other machines, which are engineered to mechanize a single task, a computer can be programmed to perform many different tasks. Although its hardware is designed for a very
specific task—the mechanization of arithmetic—computer software programs enable the
computer to perform a wide variety of tasks, from navigational control of the space shuttle
to word processing to musical composition.

(a)

(b)

Figure 1.2  (a) Pascaline. (b) Leibnitz’s calculator. (Images courtesy of the Computer History

Museum.)

K11207.indb 4

6/15/12 10:06 AM


Introduction to Computing    ◾    5  

The Jacquard loom (Figure  1.3a), invented in 1801 by the Frenchman Joseph Marie
Jacquard, is an early example of a stored program automatically controlling a hardware
device. Holes punched in metal cards directed the action of this loom: a hole punched in
one of the cards would enable its corresponding thread to come through and be incorporated into the weave at a given point in the process; the absence of a hole would exclude
an undesired thread. To change to a different weaving pattern, the operator of this loom
would simply switch to another set of cards. Jacquard’s loom is thus one of the first examples of a programmable machine, and many later computers would make similar use of
punched cards.

(a)


(b)

(c)

Figure 1.3  (a) Jacquard Loom. (Image courtesy of the Computer History Museum.) (b) Charles
Babbage. (c) Difference Engine.

K11207.indb 5

6/15/12 10:06 AM


6    ◾    Programming in C++ for Engineering and Science

The English mathematician Charles Babbage (1792–1871) (Figure  1.3b) combined the
two fundamental concepts of mechanized calculation and stored program control. In
1822, supported by the British government, he began work on a machine that he called the
Difference Engine (Figure 1.3c). Comprised of a system of gears, the Difference Engine was
designed to compute polynomials for preparing mathematical tables.
Babbage abandoned this effort and began the design of a much more sophisticated
machine that he called his Analytical Engine (Figure 1.4a). It was to have over 50,000 components, and its operation was to be far more versatile and fully automatic, controlled by
programs stored on punched cards, an idea based on Jacquard’s earlier work. Although
this machine was not built during his lifetime, it is an important part of the history of
computing because many of the concepts of its design are used in modern computers.
For this reason, Babbage is sometimes called the “Father of Computing.” Ada Augusta
(Figure 1.4b), Lord Byron’s daughter, was one of the few people other than Babbage who
understood the Analytical Engine’s design. This enabled her to develop “programs” for the
machine, and for this reason she is sometimes called “the first programmer.” In the 1980s,
the programming language Ada was named in her honor.


(a)

(b)

Figure 1.4  (a) Analytical Engine. (b) Ada Augusta.

K11207.indb 6

6/15/12 10:06 AM


Introduction to Computing    ◾    7  

During the next 100 years, the major significant event was the invention by Herman
Hollerith of an electric tabulating machine (Figure 1.5a) that could tally census statistics
stored on punched cards. This was noteworthy because the U.S. Census Bureau feared it
would not be possible to complete the 1890 census before the next one was to be taken, but
Hollerith’s machine enabled it to be completed in 2-1/2 years. The Hollerith Tabulating
Company later merged with other companies to form the International Business Machines
(IBM) Corporation in 1924.
The development of electromechanical computing devices continued at a rapid pace for
the next few decades. These included the “Z” machines, developed by the German engineer
Konrad Zuse in the 1930s, which used binary arithmetic instead of decimal so that twostate devices could be used instead of ten-state devices. Some of his later machines replaced

(a)

(b)

Figure 1.5  (a) Hollerith’s tabulating machine. (b) Harvard Mark I. (Images courtesy of the


Computer History Museum.)

K11207.indb 7

6/15/12 10:06 AM


8    ◾    Programming in C++ for Engineering and Science

mechanical relays with vacuum tubes. Zuse also designed a high-level programming language called Plankalkül. World War II also spurred the development of computing devices,
including the Collosus computers developed by Alan Turing and a British team to break
codes generated by Germany’s Enigma machine. The best-known computer built before
1945 was probably the Harvard Mark I (Figure  1.5b). Like Zuse’s “Z” machines, it was
driven by electromechanical relay technology. Repeating much of the work of Babbage,
Howard Aiken and others at IBM constructed this large, automatic, general-purpose, electromechanical calculator, sponsored by the U.S. Navy and intended to compute mathematical and navigational tables.
In 1944, Grace Murray Hopper (1907–1992) began work as a coder—what we today
would call a programmer—for the Mark I. Later, while working on its successor, the
Mark II, she found one of the first computer “bugs”—an actual bug stuck in one of the
thousands of relays.1 To this day, efforts to find the cause of errors in programs are still
referred to as “debugging.” In the late 1950s, “Grandma COBOL,” as she has affectionately been called, developed the FLOW-MATIC language, which was the basis for COBOL
(COmmon Business-Oriented Language), a widely-used programming language for business applications.
John Atanasoff and Clifford Berry developed the first fully electronic binary computer
(Figure 1.6a), the ABC (Atanasoff-Berry Computer), at Iowa State University during 1937–
1942. It introduced the ideas of binary arithmetic, regenerative memory, and logic circuits.
Unfortunately, because the ABC was never patented and others failed at the time to see
its utility, it took three decades before Atanasoff and Berry received recognition for this
remarkable technology. Until then, the Electronic Numerical Integrator and Computer,
better known as the ENIAC (Figure 1.6b), bore the title of the first fully electronic computer.
The designers, J. Presper Eckert and John Mauchly, began work on it in 1943 at the Moore
School of Engineering at the University of Pennsylvania. When it was completed in 1946,

this 30-ton machine had 18,000 vacuum tubes, 70,000 resistors, and 5 million soldered
joints, and consumed 160 kilowatts of electrical power. Stories are told of how the lights in
Philadelphia dimmed when the ENIAC was operating. This extremely large machine could
multiply numbers approximately 1000 times faster than the Mark I, but it was quite limited
in its applications and was used primarily by the Army Ordnance Department to calculate
firing tables and trajectories for various types of artillery shells. Eckert and Mauchly later
left the University of Pennsylvania to form the Eckert-Mauchly Computer Corporation,
which built the UNIVAC (Universal Automatic Computer). Started in 1946 and completed
in 1951, it was the first commercially available computer designed for both scientific and
business applications. The UNIVAC achieved instant fame partly due to its correct (albeit
not believed) prediction on national television of the election of President Eisenhower in
the 1952 U.S. presidential election, based on 5% of the returns.
The instructions that controlled the ENIAC’s operation were entered into the machine by
rewiring some of the computer’s circuits. This complicated process was very time-consuming,
sometimes taking a number of people several days; during this time, the computer was idle.
1

K11207.indb 8

This bug has been preserved in the National Museum of American History of the Smithsonian Institution.

6/15/12 10:06 AM


Introduction to Computing    ◾    9  

(a)

(b)


Figure 1.6  (a) The ABC. (b) ENIAC. (U.S. Army photo. Image courtesy of the Computer History

Museum.)

In other early computers, the instructions were stored outside the machine on punched cards
or some other medium, and were transferred into the machine one at a time for interpretation
and execution.
It must be pointed out, however, that although men had built the machine, it was women
who learned how to make it work to solve mathematical problems that would have taken
hours by hand (Figure 1.7). And there were thousands of women doing similar work all
across the United States. A documentary called Top Secret Rosies: The Female Computers of
World War II that debuted in 2010 acknowledges their important work.2
2

K11207.indb 9

/>
6/15/12 10:06 AM


10    ◾    Programming in C++ for Engineering and Science

Figure 1.7  Men built the ENIAC, but women made it work. (U.S. Army photo.)

In 1945, Princeton mathematician John von Neumann wrote First Draft of a Report on the
EDVAC (Electronic Discrete Variable Automatic Computer) in which he described a scheme
that required program instructions to be stored internally before execution. This led to
his being credited as the inventor of the stored-program concept. The architectural design
he described is still known as the von Neumann architecture. The advantage of executing
instructions from a computer’s memory rather than directly from a mechanical input

device is that it eliminates time that the computer must spend waiting for instructions.
Instructions can be processed more rapidly and, more importantly, they can be modified
by the computer itself while computations are taking place. The introduction of this scheme
to computer architecture was crucial to the development of general-purpose computers.
The actual physical components used in constructing a computer system are its hardware. Several generations of computers can be identified by the type of hardware used. The
ENIAC and UNIVAC are examples of first-generation computers, which are characterized by their extensive use of vacuum tubes. Advances in electronics brought changes in
computing systems, and in 1958 IBM introduced the first of the second-generation computers, the IBM 7090. These computers were built between 1959 and 1965 and used transistors in place of vacuum tubes. Consequently, these computers were smaller, required less
power, generated far less heat, and were more reliable than their predecessors. They were
also less expensive, as illustrated by the introduction of the first minicomputer in 1963,
the PDP-8, which sold for $18,000, in contrast with earlier computers whose six-digit price
tags limited their sales to large companies. The third-generation computers that followed
used integrated circuits and introduced new techniques for better system utilization, such
as multiprogramming and time sharing. The IBM System/360 introduced in 1964 is commonly accepted as the first of this generation of computers. Computers from the 1980s
on, called fourth-generation computers, use very large-scale integrated circuits (VLSI) on
silicon chips and other microelectronic advances to shrink their size and cost still more
while enlarging their capabilities.
The first chip was the 4004 chip (Figure 1.8) designed by Intel’s Ted Hoff, giving birth to
the microprocessor, which marked the beginning of the fourth generation of computers.

K11207.indb 10

6/15/12 10:06 AM


×