Structure of a ‘C’ Program | Readstall

Structure of a ‘C’ Program

08-12-18 Arjun Y 0 comment

Structure of a ‘C’ Program


Every C program is consists of one or more Pre-processor commands a Global Declaration section and function (Main function is Mandatory).The Global Declaration section comes at the starting of the program ,it includes Global Variable declaration and function declarations. The Program contains its functions, block of code that perform a task within a program .

Only one function must be named main it is the starting point for the program and control of all other functions must be call in its only The declaration section and statement section are the two parts of main. The Declaration section is at the beginning of the function that describes the data which is used to the function . Declarations in a functions are know as Local declarations , these are visible only to the function.

The statement section follows the declaration section, that contains instructions to the system. Pre processor commands are special instructions to the processor that says how to prepare the program for compilation. One of the most important of the Pre processor commands, and that is used in virtually all programs, is include. It tells the Pre processor that need info from selected libraries known as header files.


//Adding of two numbers
#include<stdio.h>   //Pre-processor directives
#include<conio.h> //Pre-processor directives
void main()             //Main function
int a=10,b=5,c;     //Local variable declarations
c=a+b;                  //Statements
printf(“The sum of two numbers 10 and 5 is %d:”,c);

Leave a reply