Structure of C Program

Documentation Section
Header Files
Definition Section/Symbolic Constants
Global Declaration Section
User Define Function
void function(){
Executable Part
}
Main Function Section
Main() {
Declaration Part
Executable Part
Input / Output / Display Part
}

1. Document Section
In Document Section set of comment lines giving the name, of the program, author name date and program version. To Identify what program do and who’s  created.

2. Header Section 
In this section we write required header files or we call library files used in program.

3. Definition Section/Symbolic Constants 
Here we defines all symbolic constants,a symbolic constants are certain name that are not going to change throughout the program.

4. Global Declaration Section
This Section write global variables which is used in all over in all other parts of the program.his

5. User Define Function
This section contains all the user defined function that are call in main function.

6. Main Function
Every C Program Having Main Section where all Execution part works. The main function is always the first code executed when a program starts.

In Some Program User Defines Function Write in End and call before but then Error Occurs, we redefined before main. so at my opinion write user defined function before main.

Example

//Program : Example C Program
//Author : Ahirlabs
//Date : 10-5-2020
//Version : 1.0
#include<stdio.h>
#include<conio.h>
//Static Constant
#define PI 3.14
//Global
int var = 10,num,total;
int add(int x,int y){
return x+y;
}

void main(){
clrscr();
printf("Enter A Number ");
scanf("%d",&num);
printf("\n Number is %d",num);
printf("\n PI = %f",PI);
printf("\n X= %d Y= %d",num,var);
printf("\n Total = %d",add(num,var));
getch();
}

Output 

(Visited 53 times, 1 visits today)
Share with Friends :