Here is a simplified line-by-line explanation of the program
iostream(sometimes you will see
iostream.h) is the name of a file called a ``header file'' (sometimes called an ``include file''). This header file is standard and comes with the compiler, so you don't need to be concerned about where, exactly, it is found in the file system. It is a fragment of C++ code. The
#includedirective causes this standard fragment to be inserted in your code at that location.
The main module is regarded by the compiler as a function subprogram.
We will discuss the type declaration
int and the way
functions work later in this course. For now, simply use this pattern
for all of your main programs.
The statement causes the character string
to be written to the console. This is a simple C++ statement. All
simple statements must end with a semicolon
\n means ``end of line'' and breaks the
line on your console, but is otherwise invisible. The double quotes
are used to specify the beginning and ending of the character string.
cout specifies the console screen (i.e. the
standard output device) and the
<< is an operator that
cout to cause what comes next to be sent to the
console. As a mnemonic, think of the operator as an arrow that
specifies that information flows to the console.