gettng wrong answer..

#include<stdio.h>
int main()
{ float bal,chr=0.50;
int wid;
scanf("%d",&wid);
scanf("%f",&bal);
if((bal>0&&bal<=2000)&&(wid>0&&wid<=2000)&&(wid+chr<=2000))
{
if(wid%5==0)
bal=bal-(wid+chr);
else if((wid%5!=0)||(bal<=wid))
bal=bal;
}
printf("%f",bal);
return(0);
}

1 Like

Please use the forum for reading, not only for writing, you will find help in one of those - Topics tagged atm

1 Like

you need to check your code for corner cases too…
example: your code fails when balance=120.4 and withdrawal amount=120 shows negative balance!

1 Like

First thing is you have not set any precision in the output which is mentioned in the ATM question. you can do it by giving the output like this:-

printf("%0.2f",bal);

Commenting your own posts? You can edit it or cannot you?