C Program Structure

In this tutorial you will learn about the C Program Structure and its application with practical example.

Like any other programming language c language have specification available for program structure, every c program is consist of following building blocks –


  • Documentations block
  • Preprocessor Statements – Link Preprocessors, Definition Preprocessors
  • Global declarations
  • The main ( ) function
  • Local Declarations
  • Program statements
  • User defined functions

Documentations Block

Documentation block is the header of any c program structure which is mainly consist of set of comments, that is used to provide the information about the program written like name of a program, utility of program, date of creation, date of last modification ,author name, licensing or copyrights information and any other information that programmer wish to put for the references.



Preprocessor Statements

This is the section where we define all the preprocessor directive, preprocessor statement begins with # symbol.Preprocessor statements tells the compiler to include C preprocessors directives such as header files and constants prior to compilation of the C program. Preprocessor statements are further categories as below –

Link Preprocessor- These preprocessor directive tell the compiler to link the functions from system library.


Definition Preprocessor – This the section where we define all our symbolic constant we gonna use in our program.


Global Declarations

This is the section where all the global variable and function declaration comes. All the variables and function defined or declared outside the main function are treated as global.

The main ( ) function

This is the most vital part of any each and every C program, it is mandatory for C program to have only one main ( ). The C program execution starts with main ( ) function. C program can not be executed without the main function.It is illegal to terminate it by semicolon. The main ( ) is building block where all the logic of the program comes into the picture.The main ( ) is responsible for the execution of all the user defined statement, functions and library functions. The main ( ) function further structured into – Local variable declaration, function declaration and user defined executable statements.

Local Declarations

In this section we declare all the variable that will be used in main ( ) function.Here we can also declare arrays, functions, pointers etc. These variables can also be initialized with basic data types and initial values. For examples.


  • All the local variable declaration is done in variable declaration section.
  • main ( ) function can further have the declaration for user defined functions.
  • All the user defined function’s definition appears immediately after the main function.

Program statements

This is the section where we place our main logic of the program which included the executable statements, that tell the computer to perform a specification action.Program statement can be an input-output statements, arithmetic statements, control statements, simple assignment statements and any other statements and it also includes comments that are enclosed within /* and */ . The comment statements are ignored during the compilation and execution of the program and each executable statement must be ended with semicolon.

  • main ( ) function should contain atleast one executable statement.
  • All statements in the declaration and executable parts end with a semicolon.

User defined functions

This is the section of C Program where we put all the user defined sub-program or custom functions created to perform a specific task. A user defined function must be defined before use it. User defined function can written before or immediately after the main ( ) function and called inside the main ( ) function.

In this tutorial we have learn about the C Program Structure and its application with practical example. I hope you will like this tutorial.