Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
18 views3 pages

Structure of A C Program

A 'C' program is structured into six sections: Documentation, Link, Definition, Global Declaration, main() function, and Subprogram. The Documentation section includes comments for clarity, while the Link section allows the use of built-in functions from system libraries. The main() function is essential as it marks the program's entry point, and the Subprogram section contains user-defined functions.

Uploaded by

chaduvu12
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views3 pages

Structure of A C Program

A 'C' program is structured into six sections: Documentation, Link, Definition, Global Declaration, main() function, and Subprogram. The Documentation section includes comments for clarity, while the Link section allows the use of built-in functions from system libraries. The main() function is essential as it marks the program's entry point, and the Subprogram section contains user-defined functions.

Uploaded by

chaduvu12
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

STRUCTURE OF A ‘C’ PROGRAM:

A ‘C’ Program contains the following sections:

1. Documentation Section
2. Link Section
3. Definition Section
4. Global Declaration Section
5. main() function Section
6. Sub program Section

1. Documentation Section: It consists of a set of comment lines


which contain user interested details like name of author, program and
any other details which makes the program more easy to understand.

Comment lines should be enclosed within /* and */ and can appear


anywhere in the program. These comment lines are omitted by the
compiler at the time of compilation.
E.g.,

/* program 1 */

/* VNR college */

2. Link Section: ‘‘C’ has a rich set of built-in functions and they can
be used to write any complex program. These functions are kept in
various system libraries such as

stdio.h (standard input-output header file), math.h (mathematical


functions header file), ctype.h (character testing and conversion
functions header file), string.h (string manipulations header file),
conio.h (configuration input-output header file) etc.

If we want to use the functions of these libraries, we have to provide


information to the compiler to link the functions from the corresponding
system library. This can be achieved through the link section of the ‘C’
program structure by using #include directive.

E.g., #include<stdio.h> #include<math.h>

3. Definition Section: Some problems require constant values to


solve the problem.
Eg: Formula to find area of the circle is a= ∏r2 . Where ∏ is a constant
whose value is
3.14. Such symbolic constants can be defined in definition section using
#define directive.

E.g., #define pi 3.14

4. Global Declaration Section: Some variables are used in more than


one function, such variables are called global variables. Which are
declared in the global declaration section.

5. main( ) function Section: The main( ) indicates starting of the


program. Every ‘C’ program must have one main( ) function section.
This section contains two parts.

(a) Declaration Section

(b) Executable Section

Declaration section declares all the variables used in the executable


part and the entire code for the program is written in the executable
part.

These two parts must appear between the opening { and closing braces
}. The program execution begins at the opening brace and ends at the
closing brace. All the statements in the declaration part and executable
part end with a semicolon (;).

Syntax:-

main( )

declaration part;

executable part;

6. Subprogram Section: This section consists of one or more


functions which are defined by the user. These functions can be called
from the main( ) function or any other user-defined function.

NOTE:- All sections except the main( ) function section may be absent
whey they are not required.

You might also like