Simple Program in C++ with Explanation:
In this tutorial, I will teach you how to write a simple hello world program in c++. Write the below code or Copy and paste the below code into your IDE(integrated development Environment). If you don’t know what IDE is?.
So IDE is a platform in which you write your code. If you want detail then on this website go to the programming tab and search for c++ and then you will find a complete topic about IDE. So let’s start with a simple program in C++.
how to write a simple program in C++ to print Hello Word?
#include<iostream> //iostream liberary
using namespace std
int main() //main function
{
cout<<"Hello Word"; //printing Hello Word Statement
return 0; //return Statement
}
C++ Simple Program Explanation:
Now I am explaining each and every part of the above program.
#include
means to include your header file in a program.
iostream:
it is a header file
using namespace std
If we do not write using namespace std then we have to write cout : : in this form
int
It is a data type we will discuss later.
main()
It is the main function from which our program really begins.
Body
Between Two curly braces is the main body of a program you have to write all the statements in this body.
cout<<
It is the output statement in C++. It means that it displays this data on screen during program execution.
<<
It is called an extraction operator. Normally we use this operator with cout in c++.
>>
It is called the insertion operator. Normally we use this operator with cin>> which is an input function in C++. Mean through cin>> we input our data in our program.
;
It is called statement terminator;.In c++ program we terminate our statement through simicolon( ; ).
You must enter the statement terminator at the end of every statement to avoid a compilation error.
I hope you understand, how to write the Hello World program in C++. If you are facing any problems regarding this program, then comment below or ping us on our Facebook page I will be there to help you.