Question is in the title really; I\'m sure there is something logical, but for now I\'m stumped!
Insertion operator >>
and <<
are used with Input Stream and Output Stream respectively because Input stream
means flow of data into your program and Output stream means flow of data out of your program.
As these insertion operators look like Directional operator (Showing direction of flow of data),
so >>
is chosen for Input stream and <<
for the Output stream.
Have a look at the part of code...
int Num1;
cin >> Num1;
here if you observe carefully >>
is showing flow of data to variable (declared in program)
that means the flow of data to the program , which is a job of Input stream (here cin
).
similarly goes with cout
,
int Num2 = 5;
cout << Num2;
Here <<
showing the flow of data out of the program (as Num2
is part of the program), which is the job of Output stream.
I hope all this make sense to you.