cout and cin in C++


Prev Tutorial Next Tutorial

cout and cin in C++

cout<<: cout is used for print message on screen

Example

	
#include<iostream.h>
#include<conio.h>

void main() 
{  
 int num;  
 clrscr();  
 cout<<"Hello word !";  // print message on screen
 getch();  
}  

Output

	
Hello word !

cin

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

Advertisements




Facebook Likes

Advertisements