printf("How much of a bonus did you get? ");
scanf(" %f", &a);
b = .85 * a;
printf("If you give 15 percent to charity, you will still ");
printf("have %.2f.", b);
return 0;
}
This program listing is identical to the previous program, except that this one includes whitespace and
line breaks. The physical length of a program does not determine readability; the amount of
whitespace does. (Of course, a few comments would improve this program, too, but the purpose of
this exercise is to show you the difference between no whitespace and good whitespace.)
Note
You might be wondering why the first line of the squeezed program, the one with the
#include, did not contain code after the closing angle brace. After all, the point of
unreadable code would seem to be made even more strong if the #include contained
trailing code. Code::Blocks (and several other compilers) refuse to allow code after a
#include (or any other statement that begins with a pound sign [#]).
A Second Style for Your Comments
Today’s C compilers support another kind of comment that was originally developed for C++
programs. With its C99 release, the American National Standards Institute (ANSI) committee
approved this new kind of comment, so you should be safe using it (unless you are using a really,
really old computer and compiler!). The second style of comment begins with two slashes (//) and
ends only at the end of the line.
Here is an example of the new style of comment:
Click here to view code image
// Another Code Example, just with a different commenting style
#include <stdio.h>
main()
{
printf("I like these new comments!"); // A simple statement
}
Either style of comment works, so the code examples throughout this book take advantage of both.
You should become familiar with both styles because each has its uses as you learn to write more
complicated programs.
The Absolute Minimum
You must add comments to your programs—not for computers, but for people. C
programs can be cryptic, and comments eliminate lots of confusion. Key points to