Anonymous

Can You Explain The Escape Sequences Use In C++ Language?

1 Answers

saima jabeen Profile
saima jabeen answered
Special non-printing characters are used to control printing on the output device. These are called escape sequence. These characters are not printed. These are used inside string constants or independently. These are written in single or double quotes,
An escape sequence is a combination of backslash"\" and a code character. The backslash is called the control character.

For example, to transfer the printing control to the next line the escape sequence is written as \n.Thus to transfer the printing control to next line, the output statement is written as;
Cout<< "I Love Pakistan\n". In the above statement \n is an escape sequence character. It shifts the printing control to the next line after the string is printed.

An escape sequence can be used any where in the out put stream. It can be used at the beginning of the string, in the middle or at the end of the string.If it is used at the beginning of the string then the string will be printed a blank line. To print the above string in three lines , the statement is written as:
Cout <<"I\n Love\n Pakistan";

Answer Question

Anonymous