{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Lecture 2

# logical operators unary and and or

This preview shows page 1. Sign up to view the full content.

This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: : • A / B * C means (A / B) * C 12 Relational and Logical Expressions • relational operators: <, <=, >=, > • equality operators: ==, != • logical operators: ! (unary), &&, || • && (and) and || (or) use short circuit evaluation. • Example: (5 == 4) && (A < B) • (5 == 5) || (A < B) 13 Implicit Type Conversion • A complicated topic, but important • Integral Promotion: char and short are converted to int. • Then the following order is used for finding a common type: • int - unsigned - long - unsigned long - float double - long double 15 Assignment • A = B + 5; • A = B = C; means B = C; A = B; (right associative) • A += B means A = A + B; • +=, -=, *=, /=, %=, ..... • A++, ++A means A = A + 1; A--, --A same • B = A++ means that the = is done FIRST 17 Conditional Expressions • Like an IF ELSE but it returns a value. • LargerAB = (A > B) ? A : B; • Conditional Expressions may be nested (if you can keep them straight...) 14 Explicit Type Conversion • Functional Format: type(expression) • float x =...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online