0 votes
in C Plus Plus by

What are the Extraction and Insertion operators in C++? Explain with examples.

1 Answer

0 votes
by
In the iostream.h library of C++, cin, and cout are the two data streams that are used for input and output respectively. Cout is normally directed to the screen and cin is assigned to the keyboard.

“cin” (extraction operator): By using overloaded operator >> with cin stream, C++ handles the standard input.

int age;

cin>>age;

As shown in the above example, an integer variable ‘age’ is declared and then it waits for cin (keyboard) to enter the data. “cin” processes the input only when the RETURN key is pressed.

“cout” (insertion operator): This is used in conjunction with the overloaded << operator. It directs the data that followed it into the cout stream.

Example:

cout<<”Hello, World!”;

 cout<<123;

Control Structures And Functions

Control Structures And Loops

Related questions

0 votes
asked Jan 7, 2022 in Data Structures & Algorithms by rajeshsharma
0 votes
asked Nov 24, 2020 in C Plus Plus by sharadyadav1986
...