• Register
632 points
7 1

 

Table of contents 
New line overview 
C++ New lines
Escape Sequence 
endl explanation 
Example (/n)
Example (/n /n)
Example (endl)
Summary 
Article Tags 

 

New Lines Overview :

To insert a new line, you can use the( \n) in c++…

C++ New Lines:
When we give string as input through the scanf function, we can't give spaces or other similar white spaces in it and so if we want to give such letters, like two parts of most names.  For this, we write the code [^ / n] in the control string of scanf, so that you can write all the letters except enter.

Escape sequence :

The control string of can be given characters that are either not printed or cannot be written normally. Such characters are written after the letter۔ and they are called escape sequences.  Is used for the line and it moves the cursor to the beginning of the new line. Just as the / t usually moves the cursor to the next tab, so too.  Goes to the beginning of the line. \ A When this character is present, a sound comes from the computer speaker. The purpose of saying this is to understand only / n. So that you can understand it well. 
Another way to insert a new line, is with the endl manipulator:

endl explanation :
And the endl works the same way, moving the cursor to the beginning of the new line. There's just a slight difference.


endl:
1.fill buffer
2.move cursor on next line
/n
1.move cursor on next line

Example ( /n)

#include <iostream>
using namespace std;

int main() {
  cout << "Hello World! \n";
  cout << "My self is Tania ";
  return 0;
}

Output
Hello world!
My self is Tania 

Example( /n/n)

#include <iostream>
using namespace std;

int main() {
  cout << "Hello World! \n\n";
  cout << "My self is Tania ";
  return 0;
}

OUTPUT 
Hello world!
Space
My self is Tania 

 Example (endl)

#include <iostream>
using namespace std;

int main() {
  cout << "Hello World!" << endl;
  cout << "My self is Tania Ishfaq ";
  return 0;
}

OUTPUT 
Hello world!
My self is Tania Ishfaq 

Summary 
Today we are understand to kodlogs website.  I try to explain the /n  and endl in c++. I hope after reading this article you will be able to understand the /n and endl in c++ . I would like to have feedback from my kodlog site. Please post your feedback, question, or comments about this article.

Article Tags 
C#|Python |Python 3|pycharm |html|java|JavaScript |cpp|code|rubi|Network | Google |html5 |php|bootstrap |string |Microsoft |variable |syntax |Coders |Codinglove|
Computerscience|wordpress|html-page|php|
Xml|game| net| list | loop | integer |float | string | double |

2 Comments

Please expand on this subject. Your ability to explain things is wonderful.

Hey Tania!!! your way of explaining and the flow is quite good… Keep sharing more...Thank you… smiley