Problem Solving And Program Design In C
In developed countries, life in the twenty-first century is conducted in
a veritable sea of computers. From the coffeepot that turns itself on
to brew your morning coffee to the microwave that cooks your breakfast
to the automobile that yon drive to work to the automated teller machine
you stop by for cash, virtually every aspect of your life depends on
computers.
This chapter introduces you to the computer and its components and to
the major categories of programming languages. 11 discusses how C
programs are processed by a computer. It also describes a systematic
approach to solving programming problems called tin-software development
method and shows you how to apply it.
1.1 Electronic Computers Then and Now
In our everyday life, we come in contact with computers frequently,
.some of as using computers for creating presentations and other
documents, tabulating data in spread¬sheets, or even having studied
programming in high school. But it wasn't always this way.
The first electronic computer was built in the late 1930s bv Dr. John
Atanasoff and Clifford Berrv at Iowa State University. Atanasoff
designed his computer to assist graduate students in nuclear physics
with their mathematical computations.
The first large-scale, general-purpose electronic digital computer,
called the EN I AC, was completed in 1946 at the University of
Pennsylvania with funding from the U.S. Army. Weighing 30 tons and
occupying a 30-by-50-foot space.
These earlv computers used vacuum tubes as their basic electronic
component. Technological advances in the design and manufacture of
electronic components led to new generations of computers that were
considerably smaller, faster, and less expensive than previous ones.
1.2 Computer Hardware
Despite
significant variations in cost, size, and capabilities, modern
computers resemble one another in many basic ways. Essentially, most
consist of the following components:
Main memory,Secondary memory, which includes storage devices such as hard dusks. CDs, DVDs, and flash drives,Central processing unit, Input devices, such as keyboards. mouses, touch pads, scanners, joysticks Output devices, such as monitors, printers, and speakers.
1.3 Computer Software
In the previous section, we surveyed the components of a computer
system, components referred to collectively as hardware. We also
studied the fundamental operations that allow a computer to accomplish
tasks: repeated fetching and execution of instructions. In this section
we focus on these all-important lists of instructions called computer
programs or computer software.
The collection of computer programs that control the interaction of the
user and the computer hardware is called the operating system (OS). The
operating system of a computer is often compared to the conductor of an
orchestra, for it is the software that is responsible for directing all
computer operations and managing all computer resources. Usually part
of the operating system is stored permanently in a read-only memorv
(ROM) chip so that it is available as soon as the computer is turned on.
A computer can look at the values in read-only memory, but can¬not
write new values to the chip. The ROM-based portion of the OS contains
the instructions necessary for loading into memory the rest of the
operating system code, which typically resides on a dusk.
Application Software
Application programs are developed to assist a computer user in
accomplishing specific tasks. For example, a word-processing application
such as Microsoft Word or OpenOffice.org Writer helps to create a
document, a spreadsheet application such as Microsoft Office Excel helps
to automate tedious numerical calculations and to generate charts that
depict data.
Computer users typically purchase application software on CDs or by
down¬loading files from the Internet and install the software by copying
the programs to the hard disk. When buying software, you must always
check that the program you are purchasing is compatible with both the
operating system and the computer hardware you plan to use.
Computer Languages
Developing new software requires writing lists of instructions for a
computer to execute. However, software developers rarely write in the
language directly understood by a computer, since this machine language
is a collection of binary numbers.
1.4 The Software Development Method
Programming is a problem-solving activity. If you are a good problem
solver, you have the potential to become a good programmer. Therefore,
one goal of this book is to help you improve your problem-solving
ability. Problem-solving methods are covered in many subject areas.Programmers use the software development method.
1.5 Applying the Software Development Method
Throughout this book, we use the first five steps of the software
development method to solve programming problems. These example
problems, presented as Case Studies. begin with a problem statement As
part of the problem analysis, we identify the data requirements for the
problem, indicating the problem inputs and the desired outputs. Next, we
design and refine the initial algorithm. Finally, we implement the
algorithm as a C program. We also provide a sample run of the pro¬gram
and discuss how to test the program.
Chapter Review
1. The basic coponents of a computer are main memory and secondary storag the CPU, and input and output devices.
2. All data manipulated by a computer are represented digitally, as
base 2 numbers composed of strings of the digits 0 and 1.
3. Main memory is organized into individual storage locations called memory cells.
- Each memory cell has a unique address.
- A memory cell is a collection of bytes; a byte is a collection of 8 hits.
- A memory cell is never empty, hut its initial contents may he meaningless to your program.
- The current contents of a memory cell are destroyed whenever new infor¬mation is stored in that cell.
- Programs must be loaded into the memory of the computer before they can be executed.
- Data cannot be manipulated by the computer until the)- are first stored in memory.
4. Information in secondary storage is organized into files: program
files and data files. Secondary storage provides a low-cost means of
storing large quantities of information in semipermanent form.
5. A CPU runs a computer program by repeatedly fetching and executing simple machine-code instructions.
6. Connecting computers in networks allows sharing of resources—local
resources on LANs and worldwide resources on a WAN such as the Internet
7. Programming languages range from machine language (meaningful to a
com¬puter) to high-level language (meaningful to a programmer).
8. Several system programs are used to prepare a high-level language
program for execution. An editor enters a high-level language program
into a file. A compiler translates a high-level language program (the
source program) into machine language (the object program). The linker
links thus object program to other object files, creating an executable
file, and the loader loads the exe¬cutable file into memory. All of
these programs are combined in an integrated development environment
(IDE).
Posted by 00.30 and have
0
comments
, Published at