C++ “Hello, World!” Program


Let’s start with the real coding part by practicing several programs in the C++ language. Hopefully, you all have completed the series of C++ language tutorials. Now we will practice all programs that come under the C++ language.

Meanwhile, before proceeding learners should go through the C++ language tutorial series to get depth knowledge about the basic concepts.

Implementing the theory part in the program reflects the identity of a real programmer.

Don’t practice until you get it right. Practice until you can’t get it wrong.

We are starting with the very basic code that we had already discussed in the ‘Introduction’ of c++ language i.e., printing “Hello world” on the screen.

As already said, it is a very basic code, thus requiring no complex coding part. It is to make the learners know how to start coding in C++.

Set up the environment that includes a text editor and compiler to run the code.


//C++ Hello world program


using namespace std;

int main()


cout<<"Hello! World";

return 0;





The very first statement of the code i.e.

//C++ Hello world program

will be considered as a comment. Comments are always written with // to make the code easier for the user and these comment statements are ignored by the compiler.


#include is a preprocessor directive is used for including the header file or we can say the inbuilt library of C++ programming and it is known as input-output-stream, which means it will be responsible for the user inputs and console outputs onto the screen in the whole program

using namespace std;

here std is the abbreviation for standard, which means we use all the things within the “std” namespace. There will be some predefined objects in the code. Thus, the compiler needs to know the code for those objects and their functionalities. The statement ‘using namespace std’ allows the compiler to know about the ‘cout’.

If we don’t want to use this line then we can go like this

std::cout, std::endl, etc.

After that, the ‘main’ function starts.

int main()

‘int’ denotes the integer return type of the ‘main()’ function and the curly braces after this statement represents the start and end of the function.

cout<<“Hello! World”;

‘cout’ is a predefined object used to show output on the screen. It is followed by << and the statement was written inside “” gets printed as it is.

The statement is terminated using ‘;’ i.e., the statement ends here.

return 0; It is the ending statement of the code.


In the coming programs, we will use std namespace using the code

using namespace std;

This allows us to use cout, cin, endl.

No doubt this makes our code more cleaner but it is advisable to avoid this practice once you have mastered C++.



  • Barry Allen

    A Full Stack Developer with 10+ years of experience in different domain including SAP, Blockchain, AI and Web Development.


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.