The semicolon is used to delimit declarations and statements.
In particular it follows the statements in if statements, such as
if (a == 0)
a = 2; /* the semicolon is required here */
else a = -2;
An exception is the compound statement { <statement-list> }
which is delimited by the closing brace. Therefore, it is wrong to write
if (a == 0)
{a = 2;
b = 3;
}; /* an empty statement precedes the semi-colon */
else a = -2; /* the else is out of place */
However, it is acceptable to write
for(i=0; i <= 10; i++)
{a = i;
b = a;
}; /* an empty statement follows the for statement */
but I don't do this.
Another problem is to write
for(i=0; i <= 10; i++); /* loop ends here, after null stm */
{a = i; /* compound statement follows for stm */
b = a;
}