Structure of c programing (main function is compulsory to execute any program)


  1.                                                                                    Structure of C


    1) Documentation section:- in this section you can write comments which constants of informative lines such as, about the author, about what the program is written. It gives a clear understanding to readers. Comments lines can be written in 2 different way  


1) single-line comment  

For e.g.  

// text here for single-line comment  

 

2) multi-line comments:  

For e.g.  

/* 

Here  

You  

Can  

Write multiline  

Comments  

*/  

  1.  Link section: we use the link for the headers file, in the header file there will be a pre-defined function and to use predefined functions such as input-output Getch, etc. We have to use a header such as #include <stdio.h> to use their library in the program. 

 

  1. Definition section:- we use symbolic constant in the definition section, where we can set the value of PI.  

 #define PI 3.1415 // which is a constant value  

 

  1. Global declaration section: - 

  2.  in this section, we can use the variable which we are going to use throughout the program and they are also going to use in user define as well as in the main function. 

 

  1.  Main function:- with our main function program can start, it will start from curly brackets and close with the same brackets.it can be divided into two parts  

Main( ) {  // opening  

A) declaration section  

In this section, we can define the local variable/ function  that is going to use in the program, 

 

B) executable section  

From the above declaration part, we can use the declared variable or function here to print and execute the program. 

 Every statement are closed with a semicolon (;)   for e.g.  

Printf("my name is all programing solution");  

} // closing  

 

  1. Sub-program section:- Here you can define user define a function, such as function1, function2, and so on and to execute them we call them in the main function. 

 

0 Comments