Lesson3: More on cin/cout and Escape Sequence

Console Output (cout)

As it was stated in the previous lesson, iostream includes the declarations of the basic input-output library in C++.  Talking about the output statement cout, it is simply defined as the object in C++ that displays variables, constants, literals and expressions in the screen of C++.

Example:

Picture10

.

.

.

.

.

.

.

Escape Character Sequence

Picture11

.

.

.

.

.

.

.

.

.

.

Example

Picture12

.

.

.

.

.

.

.

.

.

Console Input (cin)

Another statement defined in the C++ libarary called iostream is cin.  This is used to ask the user for a value of a variable.

Example

Picture13

.

.

.

.

.

.

.

.

.

.

.

int Age;

This is a way for the declaration of variables.  More on data types and declaration of variables will be discussed on the next lesson.

<<endl;

This has the same function with \n but instead, this is placed outside a quotation marks.

cin>>Age;

This statement would have the program ask for a value for the variable Age.

cout<<Age;

This statement asks the program to display the value for the variable Age.

Leave a comment