C ONTINUING C++ Precedence Rules, Numeric Types, More Operator Symbols, and Keyboard Input Prompts.

6
CONTINUING C++ Precedence Rules, Numeric Types, More Operator Symbols, and Keyboard Input Prompts.

Transcript of C ONTINUING C++ Precedence Rules, Numeric Types, More Operator Symbols, and Keyboard Input Prompts.

Page 1: C ONTINUING C++ Precedence Rules, Numeric Types, More Operator Symbols, and Keyboard Input Prompts.

CONTINUING C++

Precedence Rules, Numeric Types, More Operator Symbols, and Keyboard Input

Prompts.

Page 2: C ONTINUING 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

Page 3: C ONTINUING C++ Precedence Rules, Numeric Types, More Operator Symbols, and Keyboard Input Prompts.

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

Page 4: C ONTINUING C++ Precedence Rules, Numeric Types, More Operator Symbols, and Keyboard Input Prompts.

MORE OPERATOR SYMBOLS

Operator Meaning

+ Addition

- Subtraction

* Multiplication

/ Division

% Modulus (remainder from integer division)

Be careful with the order of operations!

Page 5: C ONTINUING C++ Precedence Rules, Numeric Types, More Operator Symbols, and Keyboard Input Prompts.

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) ?

Page 6: C ONTINUING C++ Precedence Rules, Numeric Types, More Operator Symbols, and Keyboard Input Prompts.

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.