In this post i am sharing structure of C Program. Actually C Program structure divided in to several sections. They are
Structure of C program is as follow:
1)Documentation:
Consist of comment that gives description of the program or programmer,problem
Ex:
/*Prog for addition of two no */
2)Link Section:
For a compiler to link function from library function.
Ex:
#include<stdio.h>
#include<conio.h>
3)Definition Section:
Define all symbolic constant.
Ex:
void()
4)Global Declaration Section:
For declaration of variable as global variable which can accessed by all function of a program.
Ex:
int x=10;
5)Main Function Section:
This the most important part of the program.It contain declaration part and execution part of program.
Ex:
main()
{
Printf("Hello World!");
}
6)Sub Program Section:
This include user define function.This function are placed after the main function.
Ex:
void()
{
printf("value inside fun() %d",a);
}
Example of C program:
Structure of C program is as follow:
1)Documentation:
Consist of comment that gives description of the program or programmer,problem
Ex:
/*Prog for addition of two no */
2)Link Section:
For a compiler to link function from library function.
Ex:
#include<stdio.h>
#include<conio.h>
3)Definition Section:
Define all symbolic constant.
Ex:
void()
4)Global Declaration Section:
For declaration of variable as global variable which can accessed by all function of a program.
Ex:
int x=10;
5)Main Function Section:
This the most important part of the program.It contain declaration part and execution part of program.
Ex:
main()
{
Printf("Hello World!");
}
6)Sub Program Section:
This include user define function.This function are placed after the main function.
Ex:
void()
{
printf("value inside fun() %d",a);
}
Example of C program:
- /*Documentation Section: program to find the area of circle*/
- #include<stdio.h> /*link section*/
- #include<conio.h> /*link section*/
- #define PI 3.14 /*definition section*/
- float area; /*global declaration section*/
- void main()
- {
- float r; /*declaration part*/
- printf("Enter the radius of the circle\n"); /*executable part starts here*/
- scanf("%f",&r);
- area=PI*r*r;
- printf("Area of the circle=%f",area);
- getch();
- }
No comments:
Post a Comment