#include<stdio.h>
int main()
{
int x;float y;
scanf("%d %f",&x,&y);
if(x%5==0 && x>0 && x<=2000 && y>0 && y<=2000)
printf("%f",y-x-0.50);
else
printf("%f",y);
return 0;
}
This code is showing wrong answer for ATM. Please help
#include<stdio.h>
int main()
{
int x;float y;
scanf("%d %f",&x,&y);
if(x%5==0 && x>0 && x<=2000 && y>0 && y<=2000)
printf("%f",y-x-0.50);
else
printf("%f",y);
return 0;
}
This code is showing wrong answer for ATM. Please help
Your problem - after each line of output, you must print āend-of-lineā character. In C++ is represented with character ā\nā. Maybe you donāt see difference on your machine, but itās a huge difference for tester, because he expected end-of-line.
So the correct code should looks like this:
if(x%5 == 0) printf("%f\n",y-x-0.5);
else printf("%f\n",y);
Now you can see, that I donāt use condition x>0 && x<=2000 && y>0 && y<=2000. Thatās because these constraints are secure in statement. Statement says, that these conditions are met for x and y on input. You donāt need to verify them.