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 trialsuresh sriramineni
779 PointsCreate a for loop that will begin with a value of 5 and end with a value of 25. In each iteration, add the incrementing
int mathTotal; bool isComplete; for (mathTotal = 5; mathTotal <25; mathTotal++); while { mathTotal=25 }
isComplete=true;
int mathTotal;
bool isComplete;
for (mathTotal = 5; mathTotal <=25; mathTotal = mathTotal++)
while {
mathTotal=25
}
isComplete = true;
Keli'i Martin
8,227 PointsHave you tried making the changes I suggested? That would definitely be a first step towards resolving your compiler errors. If you're having trouble understanding the concepts, maybe giving the videos a second look would help clarify what you're not understanding.
If after doing those things, you're still having a hard time, I'll try to help you out more. It would be beneficial for you to get a better understanding of these concepts, as they are the building blocks with which you will be building your iOS apps in the future.
Give those a try and let me know if you still need more help!
1 Answer
Keli'i Martin
8,227 PointsThere are a couple of syntax problems in your code. First, you don't need to say mathTotal = mathTotal++
at the end of your for statement. That last part just needs to increment the counter variable mathTotal
. So mathTotal++
should be all that's needed.
Next, you have a while
statement inside your for
loop. That is definitely not needed.
Lastly, what you really should be doing is declaring a new variable to use as the loop counter in your for
loop. Then, in the body of the loop, you would add that value to mathTotal
. It would look something like this:
for (int i = 5; i <= 25; i++)
{
mathTotal += i;
}
Hope this helps!
suresh sriramineni
779 Pointssuresh sriramineni
779 PointsHi Martin,
Thanks for your quick response, I am new to coding when i run above command i am getting error like:
There is a compiler error. Please click on preview to view your syntax errors! can you help me out.