Introduction
`cout` is an object in C++ that represents the standard output stream, typically the console or terminal. It is part of the `iostream` library and is used to display text or values on the screen. The `<<` operator, known as the insertion operator, is used with `cout` to output data. `cout` provides a convenient way to display information and interact with users in C++ programs. In this article, we will learn about cout in C++ in detail.

What is cout in C++?
In C++, cout is an object of the ostream class in the iostream library, which is part of the standard library. It represents the standard output stream in C++. In simpler terms, cout is the command you use when you want to send data to the standard output, which is usually your computer screen.
Syntax of Cout in C++
The syntax of `cout` in C++ is :
cout << data1 << data2 << ... << dataN << endl;
In this syntax :
1. `cout`: It is the object representing the standard output stream, typically the console or terminal.
2. `<<`: The insertion operator (`<<`) is used to pass data to the `cout` object for display. It is used between `cout` and the data you want to output.
3. `data1`, `data2`, ..., `dataN`: These represent the data or expressions that you want to display. They can be variables, literals, or any valid C++ expressions. You can output multiple data items by separating them with the insertion operator (`<<`).
4. `endl`: It is a manipulator that inserts a newline character and flushes the output buffer. It moves the cursor to the next line after displaying the data. Alternatively, you can use `\n` to insert a newline character without flushing the buffer.
Anatomy of a cout Statement
The cout statement is typically used with the insertion operator (<<), which pushes the data that follows it to the output. Here's a simple example of a cout statement:
cout << "Hello World";
Output

In this example, "Hello, world!" is a string that is sent to the output stream (i.e., displayed on your screen) when the program is run.
cout with Multiple Items
The cout statement can also output multiple items at once. Here's an example:
int apples = 5;
cout << "I have " << apples << " apples.";
Output

In this example, the sentence "I have 5 apples." will be displayed. The cout statement can seamlessly combine literals and variables for display.
Using endl with cout
endl is another important feature of cout. It stands for 'end line', and it inserts a new line character and flushes the output buffer. Here's how you can use endl:
cout << "Hello, world!" << endl;
Output

When the above code is run, "Hello, world!" is outputted and the cursor moves to the next line, ready for any subsequent output.
Also see, Abstract Data Types in C++, File Handling in CPP



