COSC-1337 Chapter 3 Flashcards
(44 cards)
“Prompt”
Lets the user know that input is expected and prompts them as to what they must enter.
A cin object must always be preceded by a “prompt”
What symbol is this? - “»”
Stream-extraction Operator
Gathering input from a users requires what process?
- “Prompting” the user to enter input
2. Using cin object to read input from the keyboard
“Input Buffer” or “Keyboard Buffer”
This is an area of memory where input from the keyboard is temporarily placed before it is converted to the correct value and stored in its variable.
What is an “Expression”?
Is something that can be evaluated to produce a single value.
“Associativity”
is the order in which an operator works with its operands. It is either left-to-right or right-to-left.
What is this for?: algebra = pow(4.0, 2);
It is the variable algebra that has an expression of 4 being raised to the second power.
What header file must be included in order to use the pow function?
What is “type coercion”?
When C++ automatically converts two values to the same type when used with an operator.
char, short, and unsigned short are automatically converted to which type?
int data type
An operator working with a lower value data type and a higher value data type will be promoted to what data type?
The higher value variable data type
When the final value of an expression (with an operator) is assigned to a variable what happens?
It is converted to the data type assigned to the variable
What happens when a floating point number is converted to an int?
It is “truncated” and the decimal gets left out
A ________ lets you manually promote or demote a value
“type cast expression”
What does this do?: static_cast(Value)
This is type conversion. It can be used to convert the data type of a variable to another.
What type cast is this?: pennies = (double)dollar;
Prefix Notation
What type conversion is this?: pennies = float(dollar);
Functional notation
High-order Bit
It is the leftmost bit. If it is 1 the number stored is negative. If it is 0 the number stored is positive.
What is a named constant/variable constant and how is it declared?
It is a variable who has a “read-only” value stored in its memory. You declare it by using “const” before declaring your variable.
How would you assign a value to multiple variables at once?
a = b = c = d = e = 12;
What direction are assignment operations carried out in?
Right to left
How do we write a stream manipulator?
setw(number)
What is the setprecision manipulator and how do we use it?
It is used to specify how many decimals we would like to be included in our cout display. It can be used as such - cout «_space;setprecision(number) «_space;variable;
How would we a float number display only 4 digits after the decimal?
cout «_space;fixed «_space;setprecision(4) «_space;variable;