22 Programming and Data Structures
Either an interpreter or compiler will do this activity.
a) Interpreters: An interpreter reads only one line of a source program at a time and converts it to
the object codes. In case of errors, the same will be indicated instantly. The program written with an
interpreter can easily be read and understood by other users. Therefore security is not provided.
Anyone can modify the source code. Hence, it is easier than compilers. However, the disadvantage
is that it consumes more time for converting a source program to an object program.
b) Compilers: Compiler reads the entire program and converts it to the object code. It provides
errors not of one line but errors of the entire program. Only error-free programs are executed. It
consumes little time for converting a source program to an object program. When the program
length for any application is large, compilers are preferred.
1.12 STRUCTURE OF A C PROGRAM
Every C program contains a number of several building blocks known as functions. Each function
performs a task independently. A function is a subroutine that may consist of one or more statements.
A C program comprises different sections which are shown in Fig. 1.27.
a) Include header file section: A C program depends upon some header files for function definitions
that are used in the program. Each header file, by default, has an extension '.h'. The file should be
included using '# include' directive as given below.
Example # include <stdio.h> or # include "stdio.h."
In this example <stdio.h> file is included, that is, all the definitions and prototypes of functions
defined in this file are available in the current program. This file is also compiled with the original
program,.
Include header file section
Global declaration section
/* comments */
main() Function name
{
/* comments */
Declaration part
Executable part
}
User-defined functions
{
}
Fig. 1.27 Structure of a C program
..................Content has been hidden....................

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