#include <stdio.h>
int main()
{
int x;
float a;
scanf("%d", &x);
scanf("%f", &a);
if(0< x <=2000 && 0<= a <= 2000) {
if(x%5 == 0) {
a = a - x-0.50;
}
}
printf("%.2f", a);
return 0;
}
#include <stdio.h>
int main()
{
int x;
float a;
scanf("%d", &x);
scanf("%f", &a);
if(0< x <=2000 && 0<= a <= 2000) {
if(x%5 == 0) {
a = a - x-0.50;
}
}
printf("%.2f", a);
return 0;
}
First of all, you don’t need to verify that the inputs are correct because they’re guaranteed.
The reason your solution is incorrect (other than maybe that 0 < x <= 2000 is not the same as 0 < x && x <= 2000), however, is because you’re not checking that the current balance is greater than the sum of the withdrawal and the bank fee.