The C language allows considerable flexibility in formatting source code. The style used in this book is recommended for program readability, but you do not have to use it when writing your programs. Below is a list of style guidelines used in this book for example programs:
Each example program begins with a comment that names the program and states what it does.
Each statement or function is listed on its own line.
Variable and function names are in lowercase, except for Windows functions, which mix uppercase and lowercase letters. The names of symbolic constants, such as TRUE and FALSE, are in uppercase.
If a function doesn't take any arguments, an opening and a closing parenthesis follow the function name with no extra space:
getch();
If a function takes arguments, a space appears after the opening parenthesis and before the closing parenthesis:
printf( "Number = %i", num_penguins );
Binary operators such as addition and subtraction are preceded and followed by a space:
3 + 5
If parentheses are used to control operator precedence, no extra spaces are included:
(3 + 5) * 2
Opening and closing braces are aligned under the first character of the controlling keyword. The block underneath is indented 3 spaces:
if( a == b )
{
c = 50;
printf( "%i\n", a );
}