why do i get wrong answers .. i use c++(gcc-4.3.2)

#include
using namespace std;
int main()
{
int x;
float y,z;
cin>>x>>y;
if (x%5 != 0){
cout<<y;
}
else if (x > y) {
cout << y;

}
else {
        y=y-(x+0.50);
cout << y;
        }

}

I am guessing this is ATM problem whose code you’ve posted here.
If I’m right,then proceed:

(Assuming that your code is correct)
Please read the output format carefully.
You are simply outputting ‘y’ whereas according to question you have to use exactly two precision units after decimal. That is why you are getting WA.

These are the thing that would be causing the wrong answer:

  1. In the loop else if (x > y + 0.5), the condition is wrong.

    Correction: It should be else if(x > y-0.5)

  2. The problem statement states that the answer should contain two digits of precision. This means that the answer should have only two digits after the decimal point.

    For this,

    Use the the setprecision() function, defined in the header file < iomanip >

` Here is how to use it with cout statement,

cout.setf(ios::fixed);

cout << setprecision(2) << y;

//