C++20 sections · 1024 units
Open in Course

The endl Keyword

Moving to next line

The endl keyword moves the cursor to the next line after printing. Without endl, all output appears on one line, which can be hard to read. Add cout << "Second line" << endl; after the first cout statement.

Run the program. You will see two separate lines because endl moved the cursor down before printing. You can also use "\n" inside a string instead of endl to create new lines. Both work the same way.

For now, use endl in all your programs.