Professional Documents
Culture Documents
Lesson 14 Cin
Lesson 14 Cin
• Variables
• Cin >> varName;
What is a Variable?
Definition of terms
• string
• char or character
• boolean of bool
• integer or int
• Floating point number (float,double)
• cin
Strings
-Is used for data values that are made up of ordered
sequences of characters, such as "hello world". A string
can contain any sequence of characters, visible or
invisible, and characters may be repeated. The number
of characters in the string is called its length, and "hello
world" has length 11 - made up of 10 letters and 1 space.
It is comprised of a set of characters that can also
contain spaces and numbers. For example, the word
"hamburger" and the phrase "I ate 3 hamburgers" are
both strings. Even "12345" could be considered a string,
if specified correctly.
The abbreviation char is short for character, which is
a data type that holds one character (letter, number,
etc.) of data. For example, the value of a char variable
could be any one-character value, such as 'A', '4', or
'#'.
In computer science, a boolean or bool is
a data type with two possible values: true
or false.
A small table that gives the memory requirement and range of float and
double is shown below –
Floating point type Memory requirement Range
±3.40282347E+38F i.e. 6-7
Float 4 bytes
significant digits
±1.79769313486231570E+
Double 8 bytes 308 i.e. 15-16 significant
digits
cin (character input)
The cin object in C++ is used to accept the input from the
standard input device i.e. keyboard.
cout = cout << varName; or cout << “ Text ”; (Display the output)