Page 37 - Modular_V1.1_Flipbook
P. 37
Escape Sequence Character Description
\’ Used to add single quote.
\” Used to add double quote.
\? Used to add question mark.
\\ Used to add backslash.
\b Used to add backspace.
\f Used to add form feed - new page.
\n Used to add line feed - new line.
\r Used to add carriage return.
\t Used to add horizontal tab.
\v Used to add vertical tab.
Let us write a C++ program to use the escape sequence characters.
#include<iostream.h>
void main()
Output:
{
The \n is used to add
cout<<”The \\n is used to add\n a line break.\n”; a line break.
The \t is used to add horizontal tab.
cout<<”The \\t is used to add\t horizontal tab.\n”;
1
cout<<”1\n1 1\n1 1 1\n1 1 1 1\n”;
1 1
}
1 1 1
COMMENTS 1 1 1 1
Comments in C++ are used to explain parts of the code. It can also be used to hide the code
as well. Comments enable us to understand the way a program works. In C++, any statement
starting with // (two forward slashes) symbol is known as a comment. C++ does not execute
comments. Comments are not a part of the program, but they do enhance the interactivity of
the program and make it readable. C++ supports two types of comments: Single line comment
and Multiple line comment.
Single Line Comment
In case a user wants to specify a single line comment, then the comment must start with the
symbol //. For example:
void main()
{
cout<<”Hello from C++.”; //Printing a message.
}
When you run the preceding code, you will get the following output:
Hello from C++.
The text next to the // will not be displayed in the output.
Input and Output in C++ 35

