Thursday 29 November 2018

what is the structure of a c++ program

Structure of a C++ program



General syntax of a C++ program is given below.

Preprocessor directives <header file>

int main()
{
Body of the program
}

Each C++ program has three main components. These are:Preprocessor directives,
Main function and body of the main function.Now,consider the following “Hello World”
Example to explain these components.

#include<iostream.h>
#include<conio.h>
int main()
{
cout<<”Hello World!”;

getch();

return 0;
}

Output of the program

Hello World!

The result of the above program is that it print “Hello World!” on the screen.It is one of
The simplest program that can be written in C++, but it contains the fundamental
Components of almost every C++ program.

0 comments: