Basic Structure of C Program

Once the coding is completed, the program is feed into the computer using a compiler to produce equivalent machine language code.

In C compilation two parts are there namely 1) Compiler and 2) Linker.

Compiler receives C source file as input and converts the file into object file.  Then the linker receives that object file as input and linking with C libraries after linking it produces executable file.  After creation of executable file then start the program execution and loads the information of the program in the primary memory through loading process after loading the information the processor processing the information and gives the output.


[Document Section]
Pre-Processor section
Link Section.
[Global declaration section]

[Local declaration section]
[Sub programming section]
[User Defined function]

Document Section: It consist the set of comment lines. The document section consists the set of comment lines giving the name of the program, author name and other details.

Link Section: It provides instructions to the compiler to link the functions from the system library.

Global Declaration Section: The variables that are used in more than one function are known as global variables and these variables are declared in the global declaration section.

Main( ) Section: Every C program must have one main function this section consists two parts namely local declaration section and statement parts.  The local declaration section declares all the variables used in statements.  The statement part consist a sequence of executable instructions.  These two parts must appear between the opening and closing curly braces.  The program execution begins at the opening brace and end at the closing brace.

Sub-Programming Section: This section consists all the user defined function.

Comments: Un executable lines in a program are called comments.  These lines are skipped by the compiler.   

//——————————–                   Single line comment

/*——————————*/                             Group of lines comment

Pre-Processor statements:- The pre processor is a program that process the source code before it passes through the compiler.

#include:  It is a pre processor file inclusion directive and is used to include header files it provides instructions to the compiler to link the functions from the system library.


# include “file name”


#include<file name>

            When the file name is included with in double quotation, the search for the file is made first the current directory and then the standard directories or the file name is included within angular bases then the file is searched only in the standard directories.

Printf( “ ”):  It is a function and is used to print data on the screen.

Syntax: int printf(“control sting”,[arg-1,arg-2,……..arg-n]);


                            (format string)

The printf statement is used to print messages, the values contain in the variable on the screen.

stdio.h:- Standard input and output header file.

conio.h:-Consol input and output header file.

Example: printf(“Welcome to C Programming”);




Void main()


            printf(“Welcome to C Programming”);


clrscr():-  It clears text mode window.

Syntax:- void clrscr();

getch():- It gets a character from console but does not echo to the screen.

Syntax:- int getch();




void main()






Follow Us On