CyberSlug Rules!

Beginner Programming CMPS060

Prof. Paulo Franca

Home

Syllabus

Login

Objects

Download

Staff only

Output with cout

Output in C++ uses an object cout where you can stream your data to the output. Notice that the arrows point from the data to cout, as opposed to what happens with cin:

cout<<x;
cin>>y;

Each item is placed in the output stream after the other with NO SEPARATION. If you want to separate the output, you have to do that yourself.

cout<<"this"<<"is"<<"it";

will write: thisisit

cout<<"this"<<" "<<"is "<<"it";

will write: this is it

The "endl" symbol is defined in "iostream.h" and can be useful to help your formatting:

cout<<name<<endl<<address; // line 1 has name, line 2, address