Nerd For Tech
Published in

Nerd For Tech

Input and Output in C++

To input and output information to the console in C++, you will use the standard input-output stream (iostream) library.

Output

To output information, you will use the code std::cout. This code is referencing the standard output stream. In most cases, the output device is the display screen.

Here is an example with the classic Hello World! program.

Input

To input information, you will use the code std::cin. This code is referencing the standard input stream. In most cases, the input device is a keyboard.

Here is an example program where the user is asked to input their name and it will get displayed back with a greeting.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store