Difference between cin and cout in cpp and how to implement it with examples. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Difference between cin and cout in cpp and how to implement it with examples.

4th Jun 2018, 12:34 PM
Deesha Devi Raghu
Deesha Devi Raghu - avatar
2 Answers
+ 5
cin is an object of the input stream and is used to take input from input streams like files, console, etc. cout is an object of the output stream that is used to show output. Basically, cin is an input statement while cout is an output statement. They also use different operators. cin uses the insertion operator( >> ) while cout uses the extraction operator( << ). For example, if you want to read an int value in a variable my_int(using cin) and then print it to the screen(using cout), you'd write: #include<iostream> int main() {    int my_int;    std::cin >> my_int;    std::cout << my_int;    return 0; }
4th Jun 2018, 12:52 PM
Prabhat Thakur
Prabhat Thakur - avatar
+ 4
cin is used to take input from the user and cout to print something...plz do take c class in sololearn app .there u can find more of it...
4th Jun 2018, 12:42 PM
Bugs-bunny
Bugs-bunny - avatar