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

In this chapter, we will explain the following:

• How a computer solves a problem

• The various stages in the development of a computer program: from

problem definition to finished program

• How a computer executes a program

• What is a “data type” and its fundamental role in writing a program

• The role of characters—the basic building blocks of all programs

• The concepts of constants and variables

• The distinction between syntax and logic errors

• How to produce basic output in C using the printf statement

• What is an escape sequence

• How descriptive or explanatory comments can be included in your program

• What is an assignment statement and how to write one in C

1.1 Programs, Languages, and Compilers

We are all familiar with the computer’s ability to perform a wide variety of tasks. For instance, we

can use it to play games, write a letter or a book, perform accounting functions for a company,

learn a foreign language, listen to music on a CD, send a fax, or search for information on the

Internet. How is this possible, all on the same machine? The answer lies with programming—

the creation of a sequence of instructions that the computer can perform (we say “execute”) to

accomplish each task. This sequence of instructions is called a program. Each task requires a

different program:

• To play a game, we need a game-playing program.

• To write a letter or a book, we need a word processing program.

1

www.it-ebooks.info

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

Saved successfully!

Ooh no, something went wrong!