|Lesson 2||Output |
|Objective || Examine simple output of a C++ program.|
Programs must communicate to be useful. Let us look at a C++ program that prints the phrase C++ is an improved C onscreen.
Move your mouse cursor over the highlighted lines of code below to receive tooltip information of their function.
Rewriting the program
While the above program is correct, we can simplify the program as follows:
//A first C++ program illustrating output
cout << "C++ is an improved C." << endl;
We use the put to operator (<<) twice with
cout. Each time we use << with
continues from the position where it previously left off.
endl flushes the output stream and adds a new line. The
endl identifier is called a
A manipulator is a value or function that has a special effect on the stream it operates on. For a complete list of C++ I/O
manipulators, click the Help button on the toolbar.