CONTINUING C++
Precedence Rules, Numeric Types, More Operator Symbols, and Keyboard Input
Prompts.
PRESEDENCE RULES
The mathematical order of operations determine to rules for C++
Highest Precedence
ParenthesisExponentsMultiplication, Division, ModulusAddition, Subtraction
Lowest Precedence
NUMERIC TYPES
Variable Type What it does
int Takes only the whole number entered, disregards decimals
float Takes into account not only the whole number, but also its decimal values
If int is used on a variable equaling 10.66, the program sees that variable as the number 10
If float is used on the variable 10.66, the program will see that variable as 10.66
MORE OPERATOR SYMBOLS
Operator Meaning
+ Addition
- Subtraction
* Multiplication
/ Division
% Modulus (remainder from integer division)
Be careful with the order of operations!
MODULUS
Modulus is the remainder you obtain from division
For Example:20 / 3 = 6 with a remainder of 2, thus 2 would be the answer for 20 % 3.
What would be the answer to 3 * 5 % 6 ?What about to 5 + 9 / (3 % 2) ?
CIN
cin is a variable that denotes an input stream The operator << is also called an insertion
operator, it follows the cin variable and is followed by where you want the variable to go into
For Example:Cin >> inches;Note: The program will wait for a value to
be inputted after the cin prompt, after you enter what the program is asking for, press enter.
Top Related