Input and Output in C++
📘 C++
👁 27 views
📅 Dec 22, 2025
⏱ Estimated reading time: 2 min
Input and output operations allow interaction between the user and the program.
1. Input in C++
C++ uses the cin object to take input from the user.
Syntax
Example
-
>>is called the extraction operator -
Takes input from the keyboard
2. Output in C++
C++ uses the cout object to display output on the screen.
Syntax
Example
-
<<is called the insertion operator -
Displays output on the screen
3. Header File Required
To use cin and cout, include:
4. Displaying Text and Variables
-
Multiple values can be displayed using
<<
5. Taking Multiple Inputs
6. New Line in Output
Using endl:
Using \n:
7. Complete Example Program
8. Input and Output with Strings
Note:
cinreads input only until a space.
Key Points
-
cinis used for input -
coutis used for output -
>>and<<are stream operators -
endlmoves the cursor to a new line
Conclusion
Input and output operations are essential for making C++ programs interactive and user-friendly.
🔒 Some advanced sections are available for Registered Members
Register Now
Register Now
Share this Post
← Back to Tutorials