if (q==s);
cout<<fixed<<setprecision(5)<<a*z<<endl;
else cout<<fixed<<setprecision(5)<<a*x<<endl;
error: else without a previous if
Thanks in advance
Printable View
if (q==s);
cout<<fixed<<setprecision(5)<<a*z<<endl;
else cout<<fixed<<setprecision(5)<<a*x<<endl;
error: else without a previous if
Thanks in advance
That semi-colon shouldn't be there.Code:if (q==s);
I fixed your thread title
Compiler must generate an error in this case as else is being used without any if.
What compiler reading is;
It reads your if statement and as you didn't put any opening, closing bracket, so it reads ; as a statement and ignores remaining... It then takes cout object as a separate line and when it looks at else, it generates an error as there is no preceding if....