Structure of c



1. Documentation section: (optional) It is used to write comments in the program which shows the name of the author or description of the program and other details.
   Comments are of two types

Example:
  • // HERE YOU CAN WRITE YOUR COMMENTS IN A SINGLE LINE
  • // Created by buildup c language
  • /* HERE YOU CAN WRITE YOUR COMMENTS IN MULTIPLE LINES*/
  • /* Please subscribe our blog from mail notification- left sidebar */
Note that the documentation section is not executed by the compiler. In other words, it does not affect the output of your program.


2. Link section:  It gives the instruction to the compiler to link the function from the system library in the program.

Example:
#include <stdio.h>
#include <conio.h>
#include <math.h>

3. Definition section:  It defines all the symbolic constants.

Example:
void fun();

4. Global declaration section: It is used when more than one variable is used in a function. 

Example:
int a=1;

Note that we will discuss this in detail later on in chapter (FUNCTION).

5. main: Every c program have at least one main function. Your program executes from here. In which it contains two parts namely, declaration part and executable part.

Declaration part: Declares all the variables in the executable part.
Executable part: It contains statements that are to be executed by the compiler.

Example:
main()
{ execution starts

Declaration part
Executable part

execution ends}

6. Sub-program section: User-defined functions are declared and usually defined after the main() function. It deals with all the user-defined functions that are called from the main().

Example:
[User defined function[
Function 1
Function 2
.
.
.
Function n


   
   
   

Comments

Popular posts from this blog

Getting input in C

Unary Operator