0% found this document useful (0 votes)
16 views

Basic Structure of C Program

C language program how to create basic structure for beginners

Uploaded by

jmpmys
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

Basic Structure of C Program

C language program how to create basic structure for beginners

Uploaded by

jmpmys
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Basic Structure of C Program

A C program involves the following sections, 2nd, 3rd and 5th point may not be there in
few C programs:

1) Documentations (Documentation Section)


2) Preprocessor Statements (Link Section)
3) Global Declarations (Definition Section)
4) The main() function
a) Local Declarations
b) Program Statements & Expressions
5) User Defined Functions

Documentation Section

This section consists of comment lines which include the name of programmer,
the author and other details like time and date of writing the program.
Documentation section helps anyone to get an overview of the program.

Link Section

The link section consists of the header files of the functions that are used in the
program. It provides instructions to the compiler to link functions from the
system library.

Definition Section

All the symbolic constants are written in definition section. Macros are known as
symbolic constants.

Global Declaration Section


The global variables that can be used anywhere in the program are declared in
global declaration section. This section also declares the user defined functions.

main() Function Section

It is necessary have one main() function section in every C program. This


section contains two parts, declaration and executable part. The declaration part
declares all the variables that are used in executable part. These two parts must
be written in between the opening and closing braces. Each statement in the
declaration and executable part must end with a semicolon (;). The execution of
program starts at opening braces and ends at closing braces.

Subprogram Section

The subprogram section contains all the user defined functions that are used to
perform a specific task. These user defined functions are called in the main()
function.

Ex:

#include <stdio.h> //Header Files


int main() //main() Function
{
int x; //Local variable declaration
// Our first basic program in C
printf("Hello World!\n\n");
return 0;
}

You might also like