Cout and Cin Function in C++
Advertisements
Cout<< and Cin>> Function in C++
cout<< Function in C++ is used for print message on scree. and cin>> Function in C++ is used for get or read value form keyboard. The iostream library is part of the C++ standard library that deals with basic input and output.
Cout Function in C++
- cout is used for displaying data on the screen.
- The operator << called as insertion operator or put to operator.
- The Insertion operator can be overloaded.
- Insertion operator is similar to the printf() operation in C.
- cout is the object of ostream class.
- Data flow direction is from variable to output device.
- Multiple outputs can be displayed using cout.
Example Cout and Cin Function in C++
#include<iostream.h> #include<conio.h> void main() { int num; clrscr(); cout<<"Hello word !"; // print message on screen getch(); }
Output
Hello word !
Cin Function in C++
cin>>: cin is used for get or read value form keyboard.
Example
#include<iostream.h> #include<conio.h> void main() { int num; clrscr(); cout<<"Enter any number:"; cin>>num; // accept one value form keyboard cout<<"Number is: "<<num; getch(); }
Output
Enter any number :100 Number is: 100
Google Advertisment