Basic structure of "C" program
Basic structure of C program includes the
following
Components.'
1. Preprocessor directives
2. Global declaration section
3. main ()
4. A pair of flower brackets{ }
5. Declarations and statements
6. User created
sub-programs or
functions
Preprocessor directives
These statements begin with # symbol. These include
statements that direct the C
ptenprocessor to include header files
and also symbolic coistants
into.esrogram)Some of the pre-
processor statements are given below)
#include <stdio.hs For standard input/output
functions
#include "Myfile.h"
Includes htader file
a called
Mg/ajbti
#define NULL 0 Defines symbolie onstánt
a
NVLL and
assigns it a value 00
A header file is a text file that contains the
declarations for a
set of related library functions. For
example, stdio.h is header
file containingdeclaration for input/output routines.
7math.h contains mathematical functions and so
Similarly
on. The header
files also contain other information related to the use
of library
w
Overview of C Program
definition etc.
constant
as symbolic
functions, such
imust be merged with the so
header file
The required This is a c c o m n i a
compilation process.
program during the statements at the beginnie
#include
stdio.h onio t
more
o n e or
by placing For example to
include
#include <stesoh> at
the source program.
statement
use the
source program
program.
beginning of the
source
files are,
Other commonly used header
Declares various functions
used in calling
Fonio.h
-
console i/O routines.)
operating system
Declares several string-manipulation routines.
string.h-
charac
(ctype.h -
Contains information used by the
classification and character conversion macros (Su
as isalpha and toascii).
Global declaration section
Variables or functions whose existence is known in the mat
function and other user defined functions, are called the gle
variables (or functions)and their declarations are called the got
declarations."
main)
This is the main function of every C program. Execution of
C program starts with main(). It calls other library functior
and user defined functions. There must be one and only on
main0 funçtion in every C program.
A pair of fAowet braçKets (
The flower brackets indicate the body
of the program, whic
indúges instuctions to perform the required task. Opening
bracket "" músabijear immediately after the word main) anc
"closagboicket " musf földw the last instruction.
Declarations and statemenjs
The declaration represent that part of the program where all
the variables, arrays, functions and so on are declared with
thei
4 Programming Language C
initialised in this
data types. Sometimes the various elements are
part.
User created sub-programs or functions
certain
hese sub-programs created by the user to pertorm
are
tasks. These functions can also be created
COmmonly performed
before the main() functions.