A ‘C’ program consists of the following sections.
{
i) Declaration Section
ii) Executable Section
}
Documentation Section : This section is used for giving comments on the program.
Syntax : /* . . . Comments . . . */
Linkage Section : This section is used to make reference to header file.
Syntax : #include<Header file name>
Constant Definition Section : This section is used to define constants for the program.
Syntax : #define Constant name Value
Global Variable Declaration Section : This section is used to declare variables that can be shared among different functions within the program.
Syntax : Storage class Data type Variable List
Main ( ) Function Section : Every ‘C’ program will definitely have this section. This section contains two sub sections.
i) Declaration Section : This section contains local declarations for main( ) functin.
Syntax : Storage Class Data Type Variable List
ii) Executable Section : This section contains actual executable instructions for the program.
Sub Program Section : This section contains one or more user defined functions.
EXAMPLE PROGRAM:
Write a Program for preparing bills of a shop.
/* Program for Preparing Bill of a Shop*/ Documentation Section
#include<stdio.h> Linkage Section
main( ) Main( ) Function Section
{
int itemno , qty ;
float uprice , bill=0.00 ; Declaration Section
char itemname[20] ;
printf(“Enter Item No : ”);
scanf(“%d”, &itemno );
printf(“Enter Item Name : “) ;
scanf(“%s”, itemname);
printf(“Enter Quantity Taken : “); Executable Section
scanf(“%d”, &qty);
printf(“Enter Unit Price : “) ;
scanf(“%f”, &uprice) ;
bill = uprice * qty ;
printf(“Total Bill = %.2f” , bill) ;
}