Endl &/n | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Endl &/n

will it make a new single line if I put two ENDL'S?

27th Nov 2016, 5:34 PM
Dhanika Weerasekara
Dhanika Weerasekara - avatar
5 Answers
+ 3
Each endl makes the cursor go to a new line. So two endl statements will produce an empty line.
27th Nov 2016, 5:39 PM
James Flanders
+ 3
You mean like this: cout<<"Hello World!<<endl<<endl; ? yes if you write it on row 1 your next output will be on row 3. Same if you write it like this: cout<<"Hello World! \n \n"; or like this: cout<<"Hello World!\n<<endl;
27th Nov 2016, 5:42 PM
QZUIO
QZUIO - avatar
+ 1
hi, if you put it in next line, it will work. but putting both of them next to other in a line, it does not work.
27th Nov 2016, 5:39 PM
parisa
parisa - avatar
+ 1
yeah, it will create a new single line below the top line. The single endl is to move to the next line, another endl will function like an enter key on the keyboard. For using Endl and \n simultaneously, it will work only if you do it as thus: cout << "Hello World! \n" << endl; The \n must be inside the quote
27th Nov 2016, 6:53 PM
Sol
Sol - avatar
0
Also /n is just the alternative to endl
31st Dec 2016, 10:31 PM
Tails Ex Machina
Tails Ex Machina - avatar