Cout and Cin Function in C++

Advertisements

Prev Tutorial Next Tutorial

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

Prev Tutorial Next Tutorial

Google Advertisment

Buy This Ad Space @$20 per Month, Ad Size 600X200 Contact on: hitesh.xc@gmail.com or 9999595223

Magenet is best Adsense Alternative here we earn $2 for single link, Here we get links ads. Magenet

For Projects 9999595223

Google Advertisements


Buy Websites 9999595223

Buy College Projects with Documentation Contact on whatsapp 9999595223. Contact on: hitesh.xc@gmail.com or 9999595223 Try this Keyword C++ Programs

Advertisements