In this article, we will discuss the very basic and most common I/O operations required for C++ programming. C++ runs on lots of platforms like Windows, Linux, Unix, Mac, etc. This is the most basic method for handling output in C++.
The cout is used very often for printing outputs i.e.., on the monitor. The predefined object cout is an instance of iostream class. For formatted output operations, cout is used together with the insertion operator, which is written as “<<“ (i.e., two “less than” signs).
Below is the C++ program to demonstrate the use of cout object:
- #include is known as a preprocessor directive, which is used to load files.
- iostream is a header file that contains functions for input/output operations (cin and cout).
Below is the C++ program to demonstrate a manipulator that can be used with the cout object:
A computer science portal for geeks - Geekforgeeks
In this example, the user is asked for his/her city name, when the user enters his/her city it will store the city name in the name variable. After that console will print the output string. Below is the program for the same: