error C2181: illegal else without matching if

Hello everyone, I am on my second week of a C++ programming class, and I keep getting this error while working on Visual Studio 2008. I know that it is probably something simple, however after a few hours I have run out of ideas.
the piece of code that is giving me the error is:

if (number1 > number2)
{
smaller = number2;
}
cout << " The smaller number of the two is: " << smaller << endl;

if (number2 > number1)

{
smaller = number1;
}
cout << " The smaller number of the two is: " << smaller << endl;

else
cout << " The two numbers are equal." << endl;
cout << endl;
Please guide me in the right direction.
the else must go immediately after the if block
In your case you have to move the cout lines after your ifs inside the brace-blocks
Thank you so much!
Problem fixed.
Topic archived. No new replies allowed.