Tuesday 12 February 2013

cout and cin objects in C++ Programming


cout object

cout is an object. It is predefined in the headerfile iostream.h. It is used to display the information on the VDU. The general form is,

cout << list to be printed;

When this statement is executed, the list on the right hand side of the operator << is directed to the object cout and displayed on the VDU.

Rules for cout objects:
1) This should terminate with semicolon (;)
2) If the list to be printed contains more than one, each should be separated by <<.
3) The list to be printed may be variables or constants.

cin object

cin is an object. It is predefined in the header file iostream.h. It is used to give values to the variables through keyboard. The general form is,

cin >> list of variables;

When this statement is executed, the data entered through the keyboard are assigned to the list of variables on the righthand side of the operator >>.

Rules for cin objects:
1) This should terminate with semicolon.
2) The list of variables should be separated by >> operated.

0 comments:

Post a Comment

Powered by Blogger.