Anytime you have an if statement without braces following it, only the next line down is included as part of the if statement.
if (condition)
x = y; //what gets evaluated pending true condition
cout <<"whatever "; //new program statement, if statement done
else //compiler says where did this come from?
you need
if (condition)
{
x = y;
cout <<"whatever ";
}
else //immediately follows if statement because of { }
etc.