C Programming Absolute Beginner's Guide (3rd Edition)

(Romina) #1
return 0;
}

Again, there isn’t much to this code. All it does is state that a family has three children and then names
each child. I promise that, as you learn new commands, statements, functions, and operators in
upcoming chapters, your programs will get meatier. You might notice that one of the #define
constants created in the header file, MORTGAGE_RATE, is not used in this sample program. You do
not have to use every created constant if you include a header file in your program.


The program uses one variable, childname, for the name and one variable, age, for the age of
three different children, with the information overwritten in each case. This is not the wisest choice—
after all, there’s a good chance that if you write a program that needs the names of your kids, you’ll
probably be using each name more than once. But in a program like this, it’s a good reminder that you
can overwrite and change variable names, but not constants created with a #define statement.


The Absolute Minimum
C’s preprocessor directives make C see code that you didn’t actually type. The key
concepts from this chapter include:


  • Always add the proper header files, using the #include directive when using
    built-in functions. Use angled brackets (< and >) around the included filename when
    including compiler-supplied header files, and be sure to place the #include
    statements for these files before main().

  • Use quotation marks (") around the included filename when including your own
    header files that you’ve stored in your source code’s directory. You can insert your
    own header files with #include wherever you want the code inserted.

  • Use uppercase characters in all defined constant names so that you can distinguish
    them from regular variable names.

Free download pdf