C++ || Hello World!

Print Friendly, PDF & Email

This page will consist of creating the typical “hello world!” application. First, you will need to create a blank project. I am using Visual C++, but any compiler will do. When you have everything loaded up, you will start your code off by entering the headers like so into your .cpp file.

The first line’s name stands for Input/Output Stream, and overall, these header files are used to handle the input/output process within your program.

Next, you are going to add the main function. This will generally look something like this

Adding the line of “return 0” is an exit code, and will tell the computer that your program executed without errors.

We are halfway finished, now all we have to do is say hello to the world! You will do that by adding this line of code to your program, which basically outputs data to the screen

Notice you need to add double quotes around the text you wish to output to the screen. Also, I added a line break, also knowns as “endl;” into my function. This basically is like the <_br> tag in HTML.

So when you add everything together, your full code will look something like this

And there you have it. After you compile the above code (by pressing CTRL + F5 in Visual C++), you should get this as your output

Hello World

Leave a Reply