C++ Cout Cin

Cin and Cout is used under header file iostream.h. These are used for input and output of data on console screen.

Cout:

Cout is predefined object of ostream class. It is used for output on console screen. Cout is used with insertion operator (<<) to display the output on console screen.

Program For cout

#include<iostream.h>
#include<conio.h>
Void main(){
	clrscr();
	cout<<”Hello World”;
	getch();
}  

Output

Hello World

Cin

Cin is predefined object of istream class. It is used to take input on console screen from keyboard. Cin is used with extraction operator (<<) to read the input from a console.

Program For cin:

#include<iostream.h>
#include<conio.h>
Void main(){
	clrscr();
	int age;
        cout<<”Enter Age:”;
	cin>>age;
	cout<<”Age:”;
        cout<
output

Enter Age: 24
Age:24
Back To Top