Inputs and Outputs
The process of going something to computer is known as input. The input is mostly given by keyboard. A program may need certain inputs from the user for working properly. The term standard input refers to the input via keyboard.
The process of getting something from computer is known as output. The output is mostly displayed on monitor. The term standard output refers to the output displayed on monitor. The result of a program is the output of that program.
C++ uses different streams to perform input and output operations. A stream can be defined as flow of data. It is an object that is used by a program to insert or extract characters. The standard C++ library includes the header file iostream.h. it contains the declarations of all standard input and output stream objects. The header file iostream.h must be included in a program that uses any input or output statement.
By default, the term standard output refers to the output displayed on monitor. C++ uses the cout stream object to display standard output. The word ‘cout’ stands for console output. The cout object is used with insertion operator (<<). The message or the value of variable followed by the insertion operator is displayed on the screen.
The syntax of using cout object is as follows:
cout: it is the name of an object used to display standard output.
<<: It is known as insertion operator put to operator. It sends the output to cout object. The cout object then sends the output to the screen. The left side of << operator must be an output stream like cout. The right side of << operator must be an expression or manipulator. One statement can use multiple insertion operators to display the values of multiple variables or constants etc.
Variable/Constant/Expression: it is the variable, constant or expression whose value is displayed on the screen.
cout<< “The Great Americans”;
The above line will display “The Great Americans” on the screen. The string constant is always enclosed in double quotes.
The above line will display 720 on the screen. The numeric constant is not enclosed in quotation marks.
The above line will display the value of variable a on the screen. The variables are not enclosed in quotation marks.
cout<<”the value of N is “<<N;
The above line will display “The value of N is” along the value of variable N on the screen. The insertion operator is used for twice to concentrate the string value with the value of N.
Here I am going to share useful video clip which include the example for clear the ideas about C++ programming input and output concepts.
Q: Write a program that displays a message and values of integer and character variables.
Answer is given in video below
How the above program (video) works
The above program declares and initializes two variables n and ch. It displays a message “Testing output…” on the screen. It then displays the value of variables n and ch. The output appears on the same line. The output of second statement starts where the output of first statement ends.
More blogs to get me use my links, please visit
Join FILMANNEX and explore your writing power with best earnings.