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

Janson Roberts
Janson Roberts
5,071 Points

Creating A For Loop

When I try to input the for loop, I keep getting a compiler error message:

expected expression for (int i=5, i<=25, i++)

I'm not sure what to do next?

bool isComplete;
int mathTotal = 0;

for (int i=5, i<=25, i++){
  mathTotal = mathTotal + i;

2 Answers

Michael Afanasiev
Michael Afanasiev
Courses Plus Student 15,596 Points

Hi Janson,

The loop is correct although you have a small syntax error, a for loop should look like this:

for (int k = 1; k < 99; k++) {
       // do something

Hint: Notice the semicolon.

Hope this helps!