Getting WA in ATM, can someone help?

atm
c
problem

#1

#include <stdio.h>
#include <stdlib.h>

int main()
{
int x;
float y,z;
scanf("%d %f",&x,&y);
if((x<=2000) && (y<=2000))
{
 if(x>y)
{
printf("%.2f",y);
return 0;
}

if(x%5==0)
{
    z=(y-x)-.50;
    printf("%.2f",z);
}
else{
z=y;
printf("%.2f",z);
}
}
return 0;
}

#2

Unfortunately admin is a bit busy at the moment but dont worry boy, we are here to help :smiley:

The problem statement states that the account (y) should have enough money for both the transaction amount x and bank charges 0.5. i.e. x+ 0.5 >= previous balance(y) in bank. As you are checking only in the cases when x > y, you will give wrong (actually negative ) answer (-0.2) for the case x=10 and y=10.3. This satisfies x>y but x+0.5 is not greater than 10.3.