Sir, Someone have suggested to remove all display statements… I have done that. But Still I’m getting a wrong answer…

#include

using namespace std;

int main()

{

int x,y;

cin>>y;

cin>>x;

if((x%5==0)&&y>(x+0.50))

{

y=(y-(x+0.50));

cout<<y;

}

else

cout<<y;

return 0;

}

So first of all you don’t have to post your queries as a new question every time.You should have commented on your previous question only. I mean here-> https://discuss.codechef.com/questions/128544/for-my-first-question

Now coming to your solution, i made a few changes in it and got Ac. Here it is-> https://www.codechef.com/viewsolution/18787497

Now talking about changes->

- i changed the data type of y from int to double. Reason being that in the input description it is clearly mentioned that x is a positive integer but y is a non negative number which could be decimal also. Not only this we have used y>(x+0.5) inside if…(x+0.5) will be double and if y is an int, we can not compare them.
- The second change i made was in output line. In the output description of the problem it is written-

**"Output the account balance after the attempted transaction, given as a number with two digits of precision"**,two digits of precision mean your output should be correct upto two places of decimal and should contain atleast two places after decimal. It means if your answer is 120, output should be 120.00. This was not happening in your code. Have a look at this-> https://www.geeksforgeeks.org/precision-of-floating-point-numbers-in-c-floor-ceil-trunc-round-and-setprecision/

Now further if you have any query about this question, comment it here only.