“Hello, World!” is a simple program that outputs Hello, World! on your screen.

Since it’s a very simple program and beginning of every programmer’s journey starts from here, it’s always used to introduce a new programming language to a beginner.

Let’s see how C++ “Hello, World!” program works.

#include <iostream>
using namespace std;
int main(){
cout<<“Hello, World!”;
return 0;

Welcome in C++ world With Codeverb


#include It’s a standard input output header files in which includes many types of predefined functions such as cout<<, cin>>, etc.

iostream is a standard library header file that contains definitions of the standard input and output streams.

These definitions are included in the std namespace, explained below.

The standard input/output (I/O) streams provide ways for programs to get input from and output to an external system — usually the terminal.

int main() int is return type here and the main is function name for the compiler. program execution starts from this function.

By convention, a program exit code of 0 or EXIT_SUCCESS is interpreted as success by a system that executes the program.

Any other return code is associated with an error.

If no return statement is present, the main function (and thus, the program itself) returns 0 by default.

In this example, we don’t need to explicitly write return 0;.

All other functions, except those that return the void type, must explicitly return a value according to their return type, or else must not return at all.

“Hello World!” is a character string literal, or a “text literal.” The stream insertion operator for character string literals is defined in file iostream.

The semicolon (;) notifies the compiler that a statement has ended. All C++ statements and class definitions require an ending/terminating semicolon.

Why we use using namespace std in C++

This makes it so easy to run the code because otherwise, we have to write cout statements

like this:() int is return type here and main is function name for the compiler. program execution starts from this function.

std::cout << "What ";
std::cout << "Are";
std::cout << "You are you doing with Your life!";
std::cout << "i hate STDS!";

So you provide the compiler the information that you will be using the class std very frequently

so now that it knows this you don’t have to keep on including the std:: in

the beginning of each cout or cin statement.

  1. cout<< – This used for print any message in C++ on the console just like printf in c.
  2. cin>>– This statement used for input any value into a variable just like scanf in c but the difference is that we don’t use here %d,%f,%s in C++.
  3. getch() function block the output screen until the user not press any key.
  4. return 0; The return keyword is used to return a value but here we are not returning any value.
This article is written by our awesome writer
Comments to: C++ hello world program

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

Attach images - Only PNG, JPG, JPEG and GIF are supported.

New Dark Mode Is Here

Sign In to access the new Dark Mode reading option.

Join our Newsletter

Get our monthly recap with the latest news, articles and resources.

By subscribing you agree to our Privacy Policy.

Latest Articles

Explore Tutorials By Categories


Codeverb is simply an all in one interactive learning portal, we regularly add new topics and keep improving the existing ones, if you have any suggestions, questions, bugs issue or any other queries you can simply reach us via the contact page


Welcome to Codeverb

Ready to learn something new?
Join Codeverb!

Read Smart, Save Time
    Strength indicator
    Log In | Lost Password