The structure of a C program constitutes of different sections as shown below
Documentation Section:
This section is also known as the commenting section. In this section programmers write a few comments about their program which will be helpful for other programmers in the team to know about the program quickly, It contains info such as
- @author_name
- @created_date
- @project_name
- @breif_description about the program and etc.
Preprocessor directives:
The statements that start with “#” are said to be pre-processor directives, these preprocessor directives are handled by the pre-processor before the compiler starts execution.
The name itself tells, what is preprocessor means. When we write and compile our C program, the application-building process will start, where C Compiler will come into action to convert the high-level code (human-understandable) into binary code or object code (Machine understandable).
The application-building process won’t be carried out by a single program called the compiler. There are multiple programs involved in this process. such as
- preprocessor
- Compiler
- Assembler
- Linker
As we have seen in the previous article, In the very first phase we have a pre-processor. Before the compilation starts, initial processing will be done by a pre-processor such as
- Macro substitution
- Conditional compilation
- Comment removal
- Header file inclusion
Global declaration section:
In the global declaration section, we will declare the global variables which will be used among multiple functions. Statements present in this section will be accessible by all the functions in the program.
Function:
A function is a block of code. We can’t write a C program without a function. Every function block starts with { “Open curly brace” and ends with “Closed curly brace” }.
Statement:
A statement is a line of code that ends with a “Semicolon“. Every statement in C should need to end with a “Semicolon“.
Return statement:
The return statement is used to return a value from the function. In C programming, we use functions to achieve modularity.
Let us consider a small example, there are two persons as master and the slave, the master’s responsibility is to call the slave and need to ask him to do some work. After completing the work, the slave needs to report the status of the work to the master.
In the same way, one function will call another function to achieve some work. After completing the work, the “called function” should report the status to “the calling function”. This can be done by using the return statement.
Note: Please don’t bother if you didn’t understand any of the concepts above. We will learn them precisely in the later articles.