Now that you have successfully compiled and run the first sample program it is time to understand how it works.



towards this end, we will examine the program line by line. The program begins with the lines
/* Program #1 - A first C++ program.
Enter this program, then compile and run it.
*/
This is a comment. Like most other programming languages, C++ lets you enter a remark into a program's source code. The contents of a comment are ignored by the compiler. The purpose of a comment is to describe or explain the operation of a program to anyone reading its source code. In the case of this comment, it identifies the program. In more complex programs, you will use comments to help explain what each features of the program is for now and how it goes about doing its work. In other words, You can use comments to provide a "play By Pay" description of what your program does.
In C++, there are two types of comments. The one you've just seen is called a multiline comment. This type of comment begins with a /* and ends with only a */ Anything between these two comment symbols is completely ignored by the compiler. Multiline comments may be one or more lines long. The second type of comment is found a little further on in the program; we'll be discussing it shortly.
The next line of code looks like this:
#include <iostream>
The C++ language defines several headers, which contain information that is either necessary or useful to you program. For this program, the header <iostream> is needed.(it is used to support the C++ I/O system.) This header is provided with your compiler. A header is included in your program by using the
#include directive. Later in this tut, You will learn more about headers and why they are important.
The next line in the program is
using namespace std;
This tells the compiler to use the std namespace. Namespaces are a relatively recent addition to C++. Although namespaces are discussed in detail later in this tut, here is a brief description. A namespace creates a declarative region in which various program elements can be placed. Elements declared in one namespace are separate from elements declared in another. Namespaces help in the organization of large programs. The using statement informs the compiler that you want to use the std namespace. This is the namespace in which the entire Standard C++ library Is declared. By using the std, you simplify access to the standard library.
The next line in the program is
// main() is where program execution begins.
This line shows you the second type of comment available in C++: the single=line comment. Sing-line comments begin with // and stop at the end of the line. Typically, C++ programmers use mulltiline comments when writing larger, more detailed commentaries, and they use single-line comments when short remakrs are needed. However, this is a matter of personal style
