PROGRAMMING STYLE
Unlike some other programming languages (COBOL, FORTRAN, etc.,) C is a free-form_language. That is, the C compiler does not care, where on the line we begin typing. While this may be a license for bad programming. we should try to use this fact to our advantages in developing readable programs. although several alternatives styles are possible, we should select one style and use it with total consistency.
First of all, we must develop the habit of writing a program in lowercase letters. C program statements are written in lowercase letters. Uppercase letters are used for an only symbolic constant.
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 independent in the program of Fig. 5.
a = b;
x = y + 1;
z = a + x;
Can be written one line as
a = b; x = y + 1; z = a + x;
The program
main()
{
printf("hello C");
}
May be written in one line like
main() { printf ("Hello C"); }
However, this style makes the program more difficult to understand and should not be used. In this post, 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. #allaboutprogramming62
Office Executive – ICICI Bank Jobs in Phaltan (₹1.8L–₹2.5L a year)
ReplyDeleteClick Here to Apply