Dejoy
asked

Expert
Palistha Singh answered
endl in C++ stands for "end line". It's used to move the output to the next line, just like pressing Enter on the keyboard.
For example:
cout << number1 << endl;
This prints the value of number1, then moves the cursor to the next line before printing anything else.
We can clearly see this in the practice exercise:
int number1 = 89;
int number2 = 313.78;
cout << number1 << endl;
cout << number2;
Output with endl:
89
313.78
Without endl (if we wrote cout << number1;):
89313.78
So endl helps keep output clean and readable by separating it into lines.
C++
This question was asked as part of the Learn C++ Basics course.
Our Experts
Sudip BhandariHead of Growth/Marketing
Apekchhya ShresthaSenior Product Manager
Kelish RaiTechnical Content Writer
Abhilekh GautamSystem Engineer
Palistha SinghTechnical Content Writer
Sarthak BaralSenior Content Editor
Saujanya Poudel
Abhay Jajodia
Nisha SharmaTechnical Content Writer
Udayan ShakyaTechnical Content Writer