Program Development Styles and Basics of C 23
b) Global declaration: This section declares some variables that are used in more than one function.
These variables are known as global variables. This section must be declared outside of all the
functions.
c) Functionmain (): Every program written inC language must contain main () function. Empty
parenthesis after main is necessary. The function main () is a starting point of every C program.
The execution of the program always begins with the function main (}. Except the main() function,
other sections may not be necessary. The program execution starts from the opening brace ({) and
ends with the closing brace (}). Between these two braces, the programmer should declare declaration
and executable parts.
d) Declaration part: The declaration part declares the entire variables that are used in the executable
part. Initializations of variables are also done in this section. Initialization means providing initial
value to the variables.
e) Executable part: This part contains the statements following the declaration of the variables.
This part contains a set of statements or a single statement. These statements are enclosed between
braces.
f) User-defined function: The functions defined by the user are called user-defined functions. These
functions are generally defined after the main () function. They can also be defined before main ()
function. This portion is not compulsory.
g) Comments: Comments are not necessary in the program. However, to understand the flow of a
program, the programmer can include comments in the program. Comments are to be inserted by
the programmer. These are useful for documentation. The clarity of the program can be followed if
it is properly documented.
Comments are nothing but some kind of statements which are to be placed between the delimiters
/*&*/. The compiler does not execute comments. Thus, we can say that comments are not the part
of executable programs.
The user can frequently use any number of comments that can be placed anywhere in the program.
Please note that comment statements can be nested. The user should select the OPTION MENU of
the editor and select the COMPILER-SOURCE —NESTED COMMENTS ON/OFF). The comments
can be inserted with a single statement or in nested statements.
Example
/* This is single comment */
/* This is an example of /* nested comments */*/
/* This is an example of
comments with multiple lines */ /* It can be nested */
1.13 PROGRAMMING RULES
The programmer, while writing a program, should follow the following rules.
1) All statements should be written in lowercase letters. Uppercase letters are only used for symbolic
constants.
2) Blank spaces may be inserted between the words. This improves the readability of the statements.
However, this is not used while declaring a variable, keyword, constant and functions.
3) It is not necessary to fix the position of a statement in the program, that is, the programmer can
write the statement anywhere between the two braces following the declaration part. The user
can also write one or more statements in one line separating them with a semicolon (;). Hence, it
is often called a free-form language.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.143.17.27