STRUCTURE OF A C PROGRAM

ARTHEESWARI . S
2 min readMar 24, 2022

Every C program consists of a number of building blocks known as functions. Each function defined in C performs a specific task. A function is subroutine the may consist of one or more statements. A C program comprises the following different sections.

A. Include header file section:

C program depends upon some header files for function definition that are used in program . Each header file by default is extended with .h .The header file should be included using #include directive as under.

For example: #include<stdio.h>

In this example ,<stdio.h> file is included ,that is, all the definitions and prototypes of function defined in this file are available in the current program. This file is also compiled with the original program.

B. Global declaration:

This section declares some variables, known as global variables, that are used in more than one function. This section must be declared outside of all the function.

C. The main() function:

This is the function with which the operating system will start execution. Each and every C program must have one and only main() function, defined as follows.

main()

{

variable declaration;

program statement;

}

Variable Declarations:

All variables used in C language programs must declared. C variable declarations include the name of the variable and its type.

Executable Statements:

Executable statement must have variable declarations. An executable statement is an expression followed by semicolon or a control construct such as IF or an WHILE statement.

Return type: return 0;

This should be included in every program you write as it is the return of the int main. The value 0 indicates that the program has been executed successfully.

--

--