ATM Code For Beginners : What Is Wrong With This Code, It's Showing WRONG ANSWER

,

#include <stdio.h>

int main()
{
int a; //withdraw amount
float b; //balance
scanf("%d",&a);
scanf("%f",&b);
if(a<=b+0.50 && a%5==0)
{
printf("%.2f",b-a-0.50);
}
else
{
printf("%f",b);
}
return 0;
}

For input 0 and 0.0 you’ll get negative answer which is not acceptable.for this case you should output available balance

1 Like