C Program Strucuture


C Program Structure.

Pre - Processor Directory( Start with # )
Global Declarations
Function Declaration
       main()
           {
              declaration section
              executable section
             getch();
           }

W.A.P to add two no:-

#include<stdio.h>
#include<conio.h>
void main()
{
  int a,b,c;
  printf("Enter first no\n");
  scanf("%d",&a);
  printf("Enter second no\n");
  scanf("%d",&b);
  c=a+b;
 
  printf("sum of a and b is "%d\n",c);
  getch();
}

Output

Enter first no
5
Enter second no
6
sum of a and b is
11

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
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 in side 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:-
getch()to hold result on screen or to view result.