Input and output operations allow interaction between the user and the program.
C++ uses the cin object to take input from the user.
>> is called the extraction operator
Takes input from the keyboard
C++ uses the cout object to display output on the screen.
<< is called the insertion operator
Displays output on the screen
To use cin and cout, include:
Multiple values can be displayed using <<
Using endl:
Using \n:
Note:
cinreads input only until a space.
cin is used for input
cout is used for output
>> and << are stream operators
endl moves the cursor to a new line
Input and output operations are essential for making C++ programs interactive and user-friendly.
Take quizzes related to this topic and see where you stand!
Start Quiz Now