Basic Structure of C Program:

            Below given the Basic structure of a  C Program.

        Documentation (comment) section

preprocessor statement

global declaration

main()

{

declarations;

statements;

}

user-defined functions



Preprocessor Statement:

These statements begin with '#' symbol. They are also called 'pre-processor directives'. These Statements directs the C processor to include header files and also symbolic constants into a C program. Some of the preprocessors are given below.

* #include <stdio.h> --> includes the standard input and output header file.

* #include <conio.h> --> includes the console input and output header file.

* #define NULL 0;    --> for defining symbolic constant NULL is equal to zero.


Global declarations:

Variables or functions whose existence is known in the main() functions and other user defined functions are called "Global Variables" and these declarations are called the "Global Declaration".


main():

As the name itself indicates, it is the main() function of every C program. Execution of C program starts from main(). No C program executed without main(). It should be written in lower case letters and should not be terminated by a semicolon. In every C program, there is only one main() function.


Curly Braces { }: 

    Every C Program uses a pair of curly braces. The left brace indicates 'Beginning' of the main() function. On the other end, the right brace indicates the 'End' of the main() function.

The braces can also be used to indicate the Beginning and End of the user-defined functions and compound statements.


Declarations:

It is a part of C program, when all the variables, arrays, functions are used in C program are declared and may be initialized with their data types.


Statements:

These are instructions to the computer to do specific operations. They may be input, output, arithmetic, control statements or other statements. They are also include comments.


User-defined functions:

These are the sub programs, generally a sub program is a functionand they contain a set of statements to perform a specific tasks. These are written by the user and hence the name 'user-defined' function. They may be written before or after main() function.


Comments:

These are explanatory note or some instructions. The statement to be commented must be enclosed within /* */ (slash star and star slash). These statements are not compiled and executed. 



/* Basic Program */

/* Hello World */ /*Comment Section*/


#include<stdio.h>                              /*Preprocessor Directives*/

main()             /*main() function */

{             /*Beginning of the function */

printf("Hello World");     /*statements*/

}                     /*End of the function */