C program structure ?


[Pre-processor directives]
[Global declaration]
[function declaration]
main()
{
[Declaration Section]
[Exexutable Section]
}

Pre-Processor directives

The pre-processor directives start with # ,these statement instruct the compiler to include some of the file in the beginning of the program for pre-define function.


Example:-#include<stdio.h>

this, is also called header file of a program.


Using the pre-processor directive the user can define the constants also:

For Example:-

#define MAX 120

#define p 3.147

 Here;    "MAX"  and  "p" is symbolic constant.


Global declarations and definitions

Global and Local there are two types of variable local variable can be declared inside a function but, The variable that are declared before all the function are called global variables. The global variable can be access by all function.


The Program header

The program execution always start from the function main and it can be written as void main()

Body of a program

A series of statement that perform a specific action will be enclosed within braces { and } it is called body of a program.

The body of a program contain two essential part:-

  • Declaration Section:-:- the variable that are used inside the function should be declared in the declaration section.
    Example:-int a,b,c,d,e  ;
  • Executable Section:- These are the building blocks of a program. They represent the instruction given to the computer to perform a specific task.
Note: An instruction may represent an expression to be evaluated input/output statement etc. each executable statement ends with “;”

getch()to hold result on screen or to view result.