Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Objective-C Basics Introduction to Operators and Conditionals Review Arithmetic Operators and Precendence

Gundra Kiran
PLUS
Gundra Kiran
Courses Plus Student 5,931 Points

(25 + 35) / 2 * (4/2) please split this for me because when I compute using precedence rule I get 15.

The way I compute is step 1: (25 + 35) / 2 * (4/2) Step 2: 60 / 2 * 2 step 3: 60 / 4 step 4: 15 but the answer you provided to me is 60, how is it possible?

1 Answer

Steven Deutsch
Steven Deutsch
21,046 Points

Hey Gundra Kiran,

The order of precedence is:

  1. Parentheses

  2. Multiplication, Divison, and Remainder

  3. Addition and Subtraction

Operators with the same priority will work from left to right. In this case:

(25 + 35) / 2 * (4/2) =

(60) / 2 * (2) =

30 * 2 = 60

Good Luck!

Gundra Kiran
Gundra Kiran
Courses Plus Student 5,931 Points

Really Great help, I appreciate your instant response Thank you.