Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS

Mark McCuller
Mark McCuller
3,539 Points

Objective-C Basics quiz on operations & expressions

I am having problems in passing this quiz on question #3 to #5. I know that from question #2 (int unstable=25, variable unstable -=5) thus the answer is unstable = 20. In question #3 “Auto increment the variable named unstable:” so 20 +1 =21 but this is wrong. What is the correct answer? In Question #4 “Auto decrement the variable named unstable:” 21 -1 =20 but this is wrong. What is the correct answer? Question #5 “Use the compact form of division to divide unstable by 3” is wrong also because question #4 is wrong. I assume the answers are added and subtracted to the unstable variable to the last question. Can someone help me understand what I am doing wrong, Thank you for your help. Mark

2 Answers

Amit Bijlani
STAFF
Amit Bijlani
Treehouse Guest Teacher

As Michael mentioned you want to use the variable and use the ++ or -- operators to auto increment or decrement. Which would mean unstable++ or unstable--;

You're 'manually' incrementing the variable by using "20+1". You'll want to use 20++. Conversely, decrementing would be --20. Compact division would be: unstable /= 3; as opposed to 'long hand' which would be unstable = unstable/3;