You are on page 1of 4

INPUT WITH cin OBJECT

cin Object is used to input values entered by the user. Let us


understand the use of cin by means of an example.
Example 3
The statement
cin >>my_variable;
causes the program to wait for the user to type in a number. The
number, which is entered, is placed in the variable my_variable.
The keyword cin (pronounced as “C in”) is an object predefined in
C++ to correspond to the standard input stream. This stream
represents data coming from the keyword. The >> is the extraction
or get from operator. It takes the value from the stream object on its
left and places it in the variable on its right.
Example 4
FLOATING POINT TYPES
Floating point numbers represent numbers with a decimal place.
Numbers like
3.145411, 32698.3221, 0.124144
are examples of floating point numbers. They have both an integer
part, to the left of the decimal point, and a fractional part, to the right.
Floating point numbers are called real numbers in mathematics.
There are three types of floating point variables in C++: type
float, type double and type long double.

Type float
This type stores numbers in the range about 3.4×10-38 to 3.4×1038,
with a precision of 7 digits. It occupies 4 bytes in memory.
Example 5
Type double and type long double
The larger floating point types, double and long double, are
similar to float except that they require more memory space and
provide a wider range of values and more precision. Type double
requires 8 bytes of storage and handles numbers in the range from
1.7×10-308 to 1.7×10308 with a precision of 15 digits.
Type long double takes 16 bytes and stores numbers in the
range of approximately 1.2×10-4932 to 1.7×104932 with a precision of
19 digits.
Example 6
Type char

char type is used to store characters.


Example 7

Type bool
Variables of type bool can have only two possible values: true and
false. Type bool gets its name from George Boole, an English
mathematician who invented the concept of using logical operators
with true-or-false values. Thus such true or false are called
boolean values.
Type bool is used in association with control structures which we
will see later on.