I have seen many people who have used std::endl or ‘n’ at the end of their output in computing olympiads, even though a newline is not needed.
For example, they often write
cout << "Hello World" << endl;
or
cout << "Hello Worldn";
instead of
cout << "Hello World";
.
Can anyone explain why this is? Like is it just a habit or is an endline actually needed?
Andrew Wang is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.