CSE 8B Chapter Stepik: Order of Precedence

58 views2 pages

Document Summary

Operators evaluated from left to right: except assignment and unary operators. These are evaluated from right to left. Some operators have the same priority ie. multiplication, division, and modulus. Solvi(cid:374)g gives us result = ((1 (4 * 3)) + 3); // b is 1, c is 2 result = -8, b = 1, c = 2. Short-circuit rule: once first true statement founded, no other relational statements are evaluated. For &&, once first statement is false, second is never evaluated. For ||, once first statement is true, second is never evaluated int d = 0; int f: boolean e = (f = 4) == 2 || d-- == 0. Then, we parenthesize the relational operators (==) After that, we put () around the entire || expression. Finally, we put () around the entire expression, including the boolean e part (boolean e = (((f = 4) == 2) || ((d--) == c)))

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents