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 Scope and Loops Review Scope and Loops

Create a for loop that will begin with a value of 5 and end with a value of 25. In each iteration, add the incrementing

Please could someone tell me the correct coding for this. The previous question asked to create int mathTotal; and bool isComplete;

The questions is Create a for loop that will begin with a value of 5 and end with a value of 25. In each iteration, add the incrementing value to mathTotal. When the loop has finished running, set 'isComplete' to true. (HINT: the last value used INSIDE the loop should be 25)

1 Answer

Jon Wood
Jon Wood
9,884 Points

I remember your code from the previous question you recently asked. When you create your loop you had i == 25. That will only execute the code inside the loop block when i is 25, so you want it to execute from 5 until 25 (inclusively).

Inside the loop block, the challenge wants you to add each iteration (i) to the mathTotal variable. Then, at the end of the loop (when i = 25) to set the isComplete variable to true.

That's a bit vague, but I wanted to help guide you before giving solutions. :) Let me know if you need more help!