PDS: CS 11002 Computer Sc & Engg: IIT Kharagpur 1
Structure of a C Program
• A program in C language is a collection of
functions and declarations. It also have C
preprocessor (cpp) directives.
• A function named ‘main()’ is mandatory.
& %
Lect 2 Goutam Biswas
, ' $
PDS: CS 11002 Computer Sc & Engg: IIT Kharagpur 2
C Function
• A function definition in C language has
– a name,
– a list of formal parameters (optional),
– type of the value it returns (if any),
– local variable declarations (if any), and
– a sequence of statementsa .
a There may be comments for better human understanding.
& %
Lect 2 Goutam Biswas
, ' $
PDS: CS 11002 Computer Sc & Engg: IIT Kharagpur 3
An Example with Three Functions
& %
Lect 2 Goutam Biswas