LAB 2.5 USING COUT, THE ENDL MANIPULATOR, AND COMMON ESCAPE SEQUENCES In C++, to output on the standard output device (usually the screen), you use cout and the stream insertion operator, <<. C++ evaluates the expression used with the stream insertion operator and prints its value at the current cursor position on the output device.You use a manipulator to format the output.The endl (the lowercase letter el, not the number 1) manipulator moves the cursor to the beginning of the next line and is called a newline character.You can accomplish the same action using the newline escape sequence \n as a character by itself or within a string.You can use multiple stream insertion operators in a single cout statement. Do not use a line wrap if an output string is too long. Close the string, go to the next line, use another insertion operator, and start a new string. If you break a string this way,remember to include blanks if appropriate. There are many escape sequences in C++ that allow you to control the output. The following are some of the commonly used escape sequences: \n Newline Cursor moves to the beginning of the next line \t Tab Cursor moves to the next tab stop \b Backspace Cursor moves one space to the left \r Return Cursor moves to the beginning of the current line (not the next line) \\ Backslash Backslash is printed \’ Single quotation Single quotation mark is printed \” Double quotation Double quotation mark is printed Comments appear in a program as explanations to the programmer and are ignored by the compiler.
Objectives In this lab, you learn to use cout and the insertion stream operator to display expressions or manipu- lators on the screen. After completing this lab, you will be able to: