Javatpoint Logo
Javatpoint Logo

C++ Manipulator endl

C++ manipulator endl function is used to insert a new line character and flush the stream.

Working of endl manipulator is similar to '\n' character in C++. It prints the output of the following statement in the next line.

Syntax

Parameter

os: Output stream object affected.

Return value

It returns argument os.

Data Races

Modifies the stream object os.

If we try to concurrent access to the same stream object, then it may cause data races, except for the standard stream objects cerr, cout, wcout, clog, wcerr and wclog when these are synchronized with stdio.

Exception Safety

Object os is in a valid state, if any exception is thrown.

Example 1

Let's see the simple example to demonstrate the use of endl:

Output:

Hello
World!

Example 2

Let's see another simple example:

Output:

Enter your roll number: 22
Hello roll number 22
Welcome to your new class!!

Example 3

Let's see another simple example:

Output:

100
3.14
314

Example 4

Let's see another simple example:

Output:

435 ms passed
894 ms passed
1326 ms passed
1747 ms passed
2178 ms passed
Next TopicC++ Manipulator





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA