ATM problem

#include
#include
using namespace std;
int main()
{
int x;
double y,a;
cin>>x;
cin>>y;
if(x%5==0)
{
if(y>=x)
{
a=y-x-0.50;
cout << fixed << setprecision(2) << a<<endl;
}
else
{
cout << fixed << setprecision(2)<<y<<endl;
}
}
else
{
cout << fixed << setprecision(2)<<y<<endl;
}
return 0;

}

WHAT IS WRONG??

if(y>=x)

If y=x, then you are printing negative value which is wrong. Please account for bank charges of withdrawal as well.

#include<stdio.h>
int main()
{
int a;
float b,s,s1;
scanf("%d%f",&a,&b);
if((a%5==0)&&(b>a)&&(b<=2000)&&(b>=0))
{
s=b-a;
s1=s-0.5;
printf("%.2f\n",s1);
}
else
{
printf("\n%.2f",b);
}
return 0;
}
why is this a wrong answer/
plz help ASAP

@naitik, Your question is answered above. If b = 100 and a = 100, You are allowing the transaction to happen. And the resulting balance is b-a-0.5 = -0.5. And of course you cannot have negative balance. So, I guess you should figure it out where you are doing it wrong.

P.S: Pleas learn how to post a question. And also how to provide a code snippet. Use the Code Sample formatting tool in the editor while typing the question. (Or select the code and press Ctrl + K).

At least you should give the link to the problem . :slight_smile: