Sunday, April 12, 2009

INPUT OUTPUT STREAMS IN C++

Input Operator
Input using insertion operator
The operator >> is known as extraction or get from operator. It extracts (or takes) the value from the keyboard and assigns it to the variable on its right. It is used to read the value from the user. This corresponds to the familiar scanf() operation.
Syntax:

cin>>variable_name;

Example:

int a;
cin>>a;
Using the above example we can read an integer value from the input device.

Output Operator

The operator << is known as insertion. It is used to write the output to the display device.

Syntax:

cout<
Example:

int a;
cout<
Using the above example we can print an integer value to the output device. It just like printf() statement is C.

No comments:

Post a Comment