Tutorial 2

Outline of program

Yes, you guessed it! This is the dreaded "Hello World" program. All we want to do here is to print out hello world to the screen and everybody is happy. Having started learning your syntax and commands you will be familiar with the fact that almost every program you write from now on will have one header file included called iostream.h, this is the standard input/output stream that contains the commands cout and cin, amongst others. For our program we know that the object is to show hello world to the screen. This means that we use the standard output and the cout command. Our program will look like the following:




Now, what does this mean? Well the #include <iostream.h> tells the compiler to include the standard input/output stream so that we can use cout. void main(void) is the main module or function of the program that will be the driver for the program. The void in the brackets tells us that the function does not take any parameters. Parameters will be explained later when we explore functions. Finally the statement cout<<"Hello World"<<endl; allows us to print hello world to the screen and start the cursor on a new line. The endl tells the program to go to the next line after the print out. Now you've successfully written your first program in C++. The best has yet to come!

Previous Tutorials Next


© Redsetter 1998