Monday, January 26, 2009

Rules for writing a C program

In the previous blogs we have learnt about the types of variables, constants and the hierarchy of operations, and now we are ready to write our first C program.
A program consists of series of consecutive steps according to the flowchart of the program or to get the desired result. And in C program each instruction is written as a separate statement and this statements must appear in the same order in which we wish them to execute, unless of course the logic of the program demands a deliberate jump or transfer of the program counter or the control to a statement, which is out of sequence.

There are some specific rules to follow, while writing C programs:

1. Blank spaces may be used between two words to improve the readability of the statement. However, no blank spaces are allowed within a variable, constants and keywords.
2. Usually all statements are written in lower case letters.
3. C language has no specific rule for the position at which a statement is to be written. That is why it is often called a free-form language
4. A C statement generally ends with a semi-colon (;)

No comments:

Post a Comment

Please give your valuable comments or queries if you fell its helpful or if you like the contents of the site. Thanks...