What is endl in c++ and how it works?

Answers (1)

Inserts a new-line character and flushes the stream.

>>It is used for putting a carriage return line feed at the end of output so the next output is on the next line, not continued on the same line

cout << "ex1" << endl << "ex 2" << " ex2";
would produce

ex1
ex2 ex2

Good day.. :)

Votes: +0 / -0