Wednesday
C++Hello World in C++!
Get started with your first program!
1. In this tutorial I’ll show you how to start your very first C++ program!
If you don’t have the appropriate tools, you can head over to Tutorial on getting started with C++ to get started right away!
2. You will also learn the structure of a C++ program.
Hello World
1. Open up your text editor, or IDE and type this in to an empty file/project.
2. Run it using the appropriate commands found in my Tutorial on getting started with C++ depending on your environment and you should see Hello World in your terminal!
So what just happened?
I’ll explain what the previous code just meant.
Includes the library iostream that contains the definitions for the input/output streams
using namespace std allows us to use the entities that correspond to std. This is something you’ll usually have in all your programs.
{
This is the main function declaration where all programs start executing. in other words, whatever commands you have after this declaration will execute sequentially.
This statement “cout” represents the output stream in C++ which outputs a sequences of characters to the stream which is usually the terminal.
“Hello World” is called a string.
\n indicates a newline.
}
This return statement causes the main function to finish executing. The zero simply means that the program finished successfully. There are other codes, but I’ll explain those later.
Structure of a C++ Program
With the basic Hello World program you should follow the following guidelines when creating any program.
using namespace std;
int main()
{
statements to execute your program
return 0;
}
Additional Resources
Getting Started for Programming shows you what you need in order to start programming.
Introduction to what C++ really is
Congratulations! You’ve made your first program! If you are having any trouble feel free to post a comment and I’ll respond promptly!



May 7, 2008
Reply
I still remember when I started this program way back! It’s pretty straightforward! If anyone has any questions, feel free to post them here!
May 9, 2008
Reply
Great article!
Jun 16, 2008
Reply
Hey awesome blog! Know anyone who would be interested in part time admin’ing a Linux box? Hit me up!