Escape Sequence in C++

Get Into Code provides you with free C++ and Java Course in Hindi/Urdu and also provides you the opportunity to practice your skills to be perfect. In the previous video we have discussed about the Character Datatype in C++. In this video we are going to discuss about Escape Sequence in C++.
Escape Sequence in C++
Escape Sequence are used to made programming easier and better for programmers in different Languages such as C++, Java . In basic Syntax of C++ of have seen that how the "endl" keyword works. It is used to end the current line and move the cursor on to Next Line. But when we have to end a line for many times then it is not a good practice to use the endl keyword. For Instance
Code Output
cout<<"Long"<<endl;
cout<<"Live"<<endl;
cout<<"Pakistan"<<endl;
Long
Live
Pakistan
Instead of this programmer practice to use \n to end the current line and move the cursor to the Next Line. For instance we can write cout<<"Long\nLive\nPakistan"; to get the same output.

Watch The Video Below To Understand Some More Escape Sequence in C++

The best about our site is that we provide our readers to practice their skills because Practice Puts Brain in Your Muscles. So, Go Ahead and Write a C++ program which print the word PAKISTAN as

P
A
K
I
S
T
A
N

Answer the Following Question to know how much you have learnt?
  1. What does the "endl" do?
    1. End the Line
    2. Move the Cursor to the next Line
    3. Both of These
  2. Which Character is used for Escape Sequence?
    1. \n
    2. \
    3. \t
  3. To remove last letter in any word, we use
    1. \e
    2. \b
    3. \n
  4. Write only a code to cout
    "2+2"
  5. Write only a code to cout
    Pakistan's Flag

No comments

Powered by Blogger.