What is the Basic Structure of C Program?

C program is structured according to a set of rules called a protocol. These rules are to be followed by the programmer when writing C code. Anything that occurs between / * and * / will not be encountered by the C compiler when compiling the code. The C compiler will ignore this part of the code during compilation.

Table of Content
  1. Documentation Section
  2. Link Section
  3. Definition Section
  4. Global Declaration Section
  5. Function Prototype Declaration Section
  6. Main Function Section
  7. Sub Program Section

Documentation Section

  • In this section, we will find a description of the program, its creation date or last modification date, an author’s name, etc.
Example
/*Author: programming-point
Date : 29/04/2021 */

  • In this section, we include the header and library files needed to run C programs.
Example
#include<stdio.h>
#include<conio.h>
#include<math.h>

Definition Section

  • This section outlines a preprocessor and a macro.
Example
#include define MAX 50;

Global Declaration Section

  • A set of global variables has been defined.
Example
int total = 0;

Function Prototype Declaration Section

  • The following section describes function return types, function parameter names, etc.
Example
int sum (int, int);

Main Function Section

  • Both the declaration section and the executable section make up the main function.
  • Whenever a function executes, it starts at the main function.
Example
main() 
{ / * Program Start * / 
  Declaration Section; 
  Executable Section; 
}  / * Program End * /

Sub Program Section / User Defined Section

  • A user defines a function that performs a specific task according to their needs.
Example
int sum (int a, int b)

Conclusion

Here is the basic structure of the C language. The key to remember is that a C program must have at least one section. I hope you found this article useful and informative. Please click the subsequent link for more information.