structure of C Program?
Ans: A C program contains one or more functions. The
statements in a C program are written in a logical sequence to perform a
specific task. Execution of a C program begins at the main() function . You can
choose any name for the functions. Every program must contain one function that
has its name as main().
STRUCTURE
OF A C PROGRAM
A
C program may contain one more sections as shown in below
Documentation
Section: The documentation section consists of a
set of comment lines giving the name of the program, the author and other
details.
Link
Section: The link section provides instructions to
the compiler to link functions from the system library.
Definition Section: The
definition section defines all symbolic constants.
Global
Declaration Section: There are some variable
that are used in more than one function. Such variables are called global
variables and are declared in the global declaration section that is outside of
all the functions. This section also declares all the user-defined functions.
main() function:
Every C program must have one main() function section. It indicates
the starting point of the program execution.
This section contains two parts, declaration part and executable
part.
The declaration part declares all the variable used in the executable part. These two
parts must appear between the opening and closing braces. This section contain
two parts i.e., i. declaration part ii. Executable part.
The program execution begins at
the opening brace and ends at the closing brace.
All statements in the declaration and executable parts end with
semicolon.
The
subprogram section contains all the
user-defined functions that are called in the main function. User-defined
functions are generally placed immediately after main function, although they
may appear in any order.
All sections
except the main function section may be absent when they are not required.
Comments
Post a Comment