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 trialRich Braymiller
7,119 Pointscompiler error?
I'm getting this error and not sure why....
"Bummer! There is a compiler error. Please click on preview to view your syntax errors!"
int mathTotal;
bool isComplete;
for (i = 5; i <= 25; i++)
{
isComplete = YES;
}
1 Answer
Steve Hunter
57,712 PointsHi Rich,
The challenge is to add up the numbers from 5 to 25 using the for
loop, storing that total in the mathTotal
variable you've created.
Once that's done, then set the isComplete
boolean to YES
. Your loop is spot on but inside it, you aren't adding i
to mathTotal
. Plus, you're setting isComplete
to YES
before i
reaches 25.
Something like this should work:
int mathTotal; // We should probably initialize this
bool isComplete;
for (int i = 5; i < 26; i++){ // or <= 25
mathTotal += i;
}
isComplete = YES;
I hope that makes sense.
Steve.