C Programming :
Unlike some other programming languages (COBOL. FORTRAN, etc.,) C is afree-form_language. That is, the C compiler does not care, where on the line we begin typing. While this may be a licence for bad programming, we should try to use this fact to our advantage in developing readable pro¬grams. Although several alternative styles are possible, we should select one style and use it with total consistency.
First of all, we must develop the habit of writing programs in lowercase letters. C program state¬ments are written in lowercase letters. Uppercase letters are used only for symbolic constants.
Braces group program statements together and mark the beginning and the end of functions. A proper indentation of braces and statements would make a program easier to read and debug. Note how the braces are aligned and the statements are indented in the program of Fig.
Since C is a free-form language, we can group statements together on one line. The statements
First of all, we must develop the habit of writing programs in lowercase letters. C program state¬ments are written in lowercase letters. Uppercase letters are used only for symbolic constants.
Braces group program statements together and mark the beginning and the end of functions. A proper indentation of braces and statements would make a program easier to read and debug. Note how the braces are aligned and the statements are indented in the program of Fig.
Since C is a free-form language, we can group statements together on one line. The statements
may be written in one line like
main( ) {printf("Hello C")};
However, this style make the program more difficult to understand and should not be used In this book, each statement is written on a separate line.
The generous use of comments inside a program cannot be overemphasized. Judiciously inserted comments not only increase the readability but also help to understand the program logic. This is very important for debugging and testing the program.
No comments:
Post a Comment