Basic Structure of C

Spread the love

C program basically consists of the following parts:−

  1. preprocessor directives Section
  2. Definition section
  3. Main Function Section
  4. Variables Section
  5. Comments Section
  6. Sub Program Section

preprocessor directives Section:- This part of the code is used to declare all the header files that will be used in the program. The first line of the program #include <stdio.h> is a preprocessor command. It  provides instruction to the compiler to link the header files or functions from the system library.

Definition section:- We define different constants. The keyword #define is used in this part.

i.e:- #define PI=3.14

Main Function Section:- Every C-programs needs to have the main function. Int main() is the main function where the program execution begins. This section contains two parts: Declaration part and Executable part.

Variables Section:- There are two types of variable.

  1. Local variable- Variables that are declared inside the main function.
  2. Global variable-  Variables that are declared outside the main function. There are some variables that are used in more than one function, such variables are called global variables.

Comments Section:- Coding description is called comments. We write comments provide information and  better understanding of the program or about lines of code.

// or /* */ used for comments in C programming.

Sub Program Section:- It contains all user-defined functions that are called in the main() function.

Disclosure: This website is supports by its reader. This means, if you buy any product / service through link on this website, we may earn a small commision withought costing you extra. Learn how you can support Us and why we need this?