One aspect of programming is the interaction with the program, in which data is entered in the program and it returns a response. The input might be an integer, a number with decimals or letters and symbols. In order to create an input you must first declare a variable that will receive the value, enter the command std::cin followed by >> and the name of variable it would represent. Also there are other several inputs used in C++ as data recovered from sensors which use different types of commands. It is important to remember that the input must be the type of the variable declared in order to avoid further complications. 

Furthermore, the output of data is done with the command std::cout followed by

Note: At the end of the lines of code, always remember to write a ; . Both instructions are included in the library iostream.

Here’s an example of a code which asks for a number and a name, and returns text related to it:

Also its important to remember to always close the ” to avoid turning large segments of the code to output. Hope this helps introduce the output and input of data in this language.

CC BY 4.0 Output and Input #Mastery10 by Carlos Gallegos is licensed under a Creative Commons Attribution 4.0 International License.