Question regarding an if statement inside a for loop

Why does this print 6 times instead of 3? I can't wrap my head around the logic behind this.

for(int i = 0; i < 6; i++)
{
if (i < 3);
   {
    cout << “ENGR 101 is a horrible class” << endl;
    }
}
if (i < 3);
Remove the ;. It terminates the if.. Your cout is not under control of the if.

PLEASE ALWAYS USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post.
http://www.cplusplus.com/articles/jEywvCM9/
Hint: You can edit your post, highlight your code and press the <> formatting button.
Topic archived. No new replies allowed.