{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# cp_1_lect_22 - Precedence Associativity of Operators High...

This preview shows pages 1–7. Sign up to view the full content.

5/10/10 Precedence & Associativity of Operators High priority * / % Low priority + - However, the order of evaluation can be changed by introducing parentheses

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Precedence & Associativity Continued… Operators Associativity Rank (),[ ] L to R 1 +, -, ++, --, !, ~, *, &, sizeof, (type) R to L 2 *, /, % L to R 3 Binary plus(+) and Binary minus (-) L to R 4 <<, >> (bitwise SHIFT, later chapters) L to R 5 <, <=, >, >= L to R 6 ==, != L to R 7 & (bitwise AND, later chapters) L to R 8 ^ (bitwise XOR, later chapters) L to R 9 | (bitwise OR, later chapters) L to R 10 && L to R 11 || L to R 12 ?: R to L 13 =, *=, /=, %=, +=, -=, &=, ^=, |=, <<=, >>= R to L 14 , L to R 15
5/10/10 Precedence & Associativity Continued… Assume a = 1, b = 2, c = 3, and d = 4. x = a * b + c * d / 2; same as: x = (a * b) + ((c * d) / 2); For long or confusing expressions, use parentheses, because reader might not

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
5/10/10 reading input through the keyboard #include <stdio.h> void main () { /* We will use a floating-point and an integer variable. */ double x; int n; /* Read in an integer. */ printf("Please enter an integer: ");
5/10/10 Implicit type conversion In all expressions except assignments, any implicit type conversions are made from lower size type to a higher size type.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
5/10/10 Type Conversions in Expressions Implicit Conversion
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 14

cp_1_lect_22 - Precedence Associativity of Operators High...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online