|
|
|
|
|
|
|
the output statement looks like this: |
|
|
|
|
|
|
|
|
To conclude this introductory look at C++ output, we should mention how to terminate an output line. Normally, successive output statements cause the output to continue along the same line of the display screen. The sequence |
|
|
|
|
|
|
|
|
writes the following to the screen, all on the same line: |
|
|
|
|
|
|
|
|
To print the two words on separate lines, we can do this: |
|
|
|
|
|
|
|
|
cout < Hi < endl;
cout < there < endl; |
|
|
|
|
|
|
|
|
The output from these statements is |
|
|
|
|
|
|
|
|
The identifier endl (meaning end line) doesn't fit the pattern in the syntax template we gave. It is neither an expression of simple type nor a string constant. It is a special C++ feature called a manipulator. We discuss manipulators in the next chapter. For now, the important thing to note is that endl lets you finish an output line and go on to the next line whenever you wish. |
|
|
|
|
|
|
|
|
Beyond Minimalism: Adding Comments to a Program |
|
|
|
|
|
|
|
|
All you need to create a working program is the correct combination of declarations and executable statements. The compiler ignores comments, but they are of enormous help to anyone who must read the program. Comments can appear anywhere in a program. |
|
|
|
|
|