08.01.2023 Views

Learn to Program with C_ Learn to Program using the Popular C Programming Language ( PDFDrive )

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 1 ■ Elementary Programming Concepts

• To do accounts, we need an accounting program.

• To learn Spanish, we need a program that teaches Spanish.

• To listen to a CD, we need a music-playing program.

• To send a fax, we need a fax-sending program.

• To use the Internet, we need a program called a “Web browser.”

For every task we want to perform, we need an appropriate program. And in order for the

computer to run a program, the program must be stored (we sometimes say loaded) in the

computer’s memory.

But what is the nature of a program? First, we need to know that computers are built to

execute instructions written in what is called machine language. In machine language, everything

is expressed in terms of the binary number system—1s and 0s. Each computer has its own

machine language and the computer can execute instructions written in that language only.

The instructions themselves are very simple: for example, add or subtract two numbers,

compare one number with another, or copy a number from one place to another. How, then, can

the computer perform such a wide variety of tasks, solving such a wide variety of problems, with

such simple instructions?

The answer is that no matter how complex an activity may seem, it can usually be broken

down into a series of simple steps. It is the ability to analyze a complex problem and express

its solution in terms of simple computer instructions that is one of the hallmarks of a good

programmer.

Machine language is considered a low-level programming language. In the early days of

computing (1940s and ‘50s) programmers had to write programs in machine language, that is,

express all their instructions using 1s and 0s.

To make life a little easier for them, assembly language was developed. This was closely

related to machine language but it allowed the programmer to use mnemonic instruction codes

(such as ADD and names for storage locations (such as sum) rather than strings of binary digits

(bits). For instance, a programmer could refer to a number by sum rather than have to remember

that the number was stored in memory location 1000011101101011.

A program called an assembler is used to convert an assembly language program into

machine language. Still, programming this way had several drawbacks:

• It was very tedious and error prone.

• It forced the programmer to think in terms of the machine rather than in

terms of his problem.

• A program written in the machine language of one computer could not

be run on a computer with a different machine language. Changing your

computer could mean having to rewrite all your programs.

To overcome these problems, high-level or problem-oriented languages were developed in

the late 1950s and ‘60s. The most popular of these were FORTRAN (FORmula TRANslation) and

COBOL (COmmon Business-Oriented Language). FORTRAN was designed for solving scientific

and engineering problems that involved a great deal of numerical computation. COBOL was

designed to solve the data-processing problems of the business community.

2

www.it-ebooks.info

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!