illegal else without matching if
When Im running my code with the Powershell, it showed that "error C2181 illegal else without matching if"
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
#include "calculate.h"
void calculate( istream& in, ostream& out )
{
string oper;
int degrees;
double radians;
double answer;
in >> oper;
in >> degrees;
while ( !in.fail() )
{
if ( oper == "sin" );
{
answer=sin(degrees*(180/M_PI));
}
else if ( oper == "cos" );
{
answer=cos(degrees*(180/M_PI));
}
else if ( oper == "tan" );
{
answer=tan(degrees*(180/M_PI));
}
in >> oper;
in >> degrees;
out << "Operations"<<"\tAngle"<<"\tAnswer"<<endl;
out << "sin" <<degrees<< answer<<endl;
out << "cos" <<degrees<< answer<<endl;
out << "tan" <<degrees<< answer<<endl;
}
}
|
Remove the semicolons from lines 13, 17 and 21.
Topic archived. No new replies allowed.