C++ Program to print Hello World – Programming, Pseudocode Example, C# Programming Example

C++ Program to print Hello World

In this program, we will print the hello world on the output screen. We will use cout object of class ostream and also have used // symbol to use comments in C++ to tell what that particular statement does.

We will print it in two different ways so that we can learn more about the cout object.

Print hello world

On separate lines

Using endl stream manipulator

We can achieve this by using the cout object. We will use endl. It is used to break the line and jump the cursor to the next line.


Using the ‘\n’ character

There is one more way of doing this. We can just include the newline(\n) character in between.

Both of the above-discussed methods will give the same output.

C++ Code on the same line

We can achieve this by printing one full string.

There is one more way, in which we will use the << operator to concatenate the two strings.





Leave a Comment

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

%d bloggers like this: