Basic Structure of C++ Program
The
format according to which a computer program is written is called the
structure of a program. The basic structure of C++ program includes
following main parts:
- Preprocessor Directives
- The main() Function
- C++ Statements
Preprocessor Directives
The
instructions that are given to C++ compiler before the beginning of the
actual program are called Preprocessor Directives. They are also known
as compiler directives.
Important Preprocessor Directives are:
- Include
- Define
C++ Header Files
It
contain the declarations of standard functions. The header files also
contain destination of various data types and constants needed by the
functions. The extension of a header file is ".h".
The main() Function
It
comes after the Preprocessor Directive. The main90 function indicates
the beginning of the C++ program. The main() function must be included
in every C++ program. When a c++ program is executed, the control goes
directly to the main() function and starts executing its statements.
C++ Statements
A
program statement is a fundamental unit of any programming languages.
It is an instruction for the computer to do something. The statements of
C++ program are written under the main() function between the curly
brackets. Each statement of C++ program ends with semicolon (;). It is statement terminator. C++ is a case sensitive language.
Post a Comment