Sams Teach Yourself C in 21 Days

(singke) #1

DAY 2


WEEK 1


The Components of a C


Program


Every C program consists of several components combined in a certain way.
Most of this book is devoted to explaining these various program components
and how you use them. To help illustrate the overall picture, you should begin
by reviewing a complete (though small) C program with all its components
identified. Today you will learn:


  • About a short C program and its components

  • The purpose of each program component

  • How to compile and run a sample program


A Short C Program ..............................................................................................

Listing 2.1 presents the source code for multiply.c. This is a very simple pro-
gram. All it does is accept two numbers that are entered from the keyboard and
calculate their product. At this stage, don’t worry about understanding the

05 448201x-CH02 8/13/02 11:14 AM Page 29

Free download pdf