62 Introduction to C++ Programming and Graphics
\’ Print a single quote (’)
\” Print a double quote (”)
\? Print a question mark (?)
\\ Print a backslash (\)
\a Sound a beep
\t Press the tab key
\v Issue a vertical tab
\r Issue a carriage return
\b Issue a backspace signal
\f Issue a page feed
\n Issue a line break
\\ Continue a string to the next line
Table 3.4.1Printing codes preceded by the backslash.
To display the values of two numerical variables separated by space and move
the cursor to the next line, we use:
cout << variable <<""<<variable1 << " total" << endl;
Material enclosed by double quotes is interpreted verbatim as text. The text
directive “\n”, and its equivalent end-of-line directive “endl”, both instruct the
cursor to move to the next line.
Other printing codes preceded by the backslash are shown in Table 3.4.1.
For example, we can sound a beep by printing:\a.
Printing characters
As an application, we consider a program contained in the filecharac-
ters.ccdemonstrating the ASCII code:
#include <iostream>
using namespace std;
int main()
{
int i;
char a;
for (i=60; i<=101; i++)
{
a=i;
cout << a;
}