Ive looked everywhere and cant figure out why I keep getting this. I have my curly braces on right I believe and when i put (this code here) after the for loop everybody said it was wrong so Im not sure what to do I been really struggling with this.

enter image description here

2 Answers 2


@CliffB's instruction is correct, but that's only part of the problem. Note that you already have a value for ht going into the loop, which is whatever value the user inputted. Therefore you shouldn't be initializing it again as

int hp=0

as this will overwrite whatever value hp has. And you want your for loop to count up to the value of hp, not reset the value of hp to 0.

  • That's true, but it had nothing to with the question. ;-) Since this is a learning environment, the trick is to only answer the question asked and to give people a chance to both find and solve the problems that follow. Points for catching it though. ;-)
    – Cliff B
    Commented Jan 15, 2017 at 9:33

The for loops are incorrectly structured. The compiler doesn't like the curly braces. The semicolon placement is a problem too. Format for a for loop is this:

for( init_clause ; test_clause ; increment_clause )
    // code block

If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .