ATM C++4.3.2: What's wrong with my code? shows wrong answer!

It means that the output is not at par! But, I am gettin’ the right output!

#include
#include
#include

using namespace std;

int main() {
int x;
float bal;
cout.setf(ios::fixed);

cin>>x;
cin>>bal;

if(x%5!=0)
{cout<<setprecision(2)<<bal;
exit(0);
}
if(x>=bal)
{ cout<<setprecision(2)<<bal;
exit(0);
}
else
{bal=bal-(x+.50);
cout<<setprecision(2)<<bal;
exit(0);
}

return 0;
}

The condition x >= bal is not correct.

It should be x+0.5 > bal

Also there is no need to use exit(0).

Use of return 0 will also work.

I have corrected your solution here’s the link: http://www.codechef.com/viewsolution/4318769

Try the case of 20 20.1 as your input

//