Thursday 13 October 2016

What is the basic structure of C++ program ?

Basic Structure:

Here I am going to tell you what is the basic structure of a C++ Program.
A syntax or a pattern to write a program is called as structure.
Here is the basic structure of C++ program:


Preprocessor Directives:

Preprocessor directives are included on the top of any C++ program. These are used to add header files to a program. Preprocessor directives start with the # sign and a keyword "include" is used with start angle bracket and end angle bracket.
Example: #include<conio.h>

Another way of including header files is #include "conio.h" but the better way to add header files is above method.

Header File:
Header file contains the libraries and function about what to do in program... like "iostream.h" it contains the input and output libraries and also general math functions.
A header file has the extension of ".h".

Main Body:

Main body contains the code section of the program. It is the place where the actual working of a program starts. All variable declaration, initialization and other things like comments are mention there.

No comments:

Post a Comment