Hey Friends, so far we have learned about some basic things of C programming language like ( Variable, Constant, Keywords, etc. ) Now today we are going to learn about the basic structure of c programming. So let’s begin..!!!
Basic Structures of C programs
Basically, any c program is divided into 6 different sections. These Six Sections are:-
1. Documentation Section
2. Link Section
3. Definition Section
4. Global Declaration Section
5. Main() Function Section
6. Subprograms Section
Below you find a brief information on them.
Basic Structure of C programs
Documentation Section
In the Documentation Section, the Programmer gives the information (Details) about the program, author, coding details, and some other stuff that is used on it. Documentation Section helps anyone (user, programmer, author, owner, etc) to get an overview of the program.
Example:-
/**
* File Name: Helloworld.c
* Author: Suresh Mishra
* Date: 24/08/2020
* Description: a program to display hello world
*/
* File Name: Helloworld.c
* Author: Suresh Mishra
* Date: 24/08/2020
* Description: a program to display hello world
*/
Link Section
Link Section is a part of code that is used to add or insert-header files that will be used on the program. This section tells the compiler to link header files from the system libraries.
Example:-
#Include <stdio.h>
#include<conio.h>
#include<conio.h>
Definition Section
In this section, we define the different constant. And also keywords as well.
Example:-
#define PI=3.14
Global Declaration Section
In this Section, Global variables are declared. All the Global Variable which is used on the program are declared in the global declaration section.
Example:-
int a=7 b= 10, float z = 7.10 etc
Main Function Section
Every C program it is necessary to have the main function. Each Main Function contains 2 parts. 1. Declaration Part and 2. Execution Part. The declaration part is the part where all the variables are declared. And the execution part always starts with curly brackets and end with curly brackets. Both the part must have inside the curly brackets.
Example:-
{
void main ()
{
Int a = 10;
printf(“%d”, a);
return 0;
}
{
Int a = 10;
printf(“%d”, a);
return 0;
}
Subprograms Section
All the user-defined functions are defined in this section of the program.
Example:-
int add(int a, int b)
{
return a+b;
}
{
return a+b;
}
In this tutorial, we learn about the basic structure of C programming. If you find any mistakes on it. Or if you have any quarry related to it please comment below. Follow us for more programming tutorials.
You May Also Like
0 comments:
Post a Comment