atm code: what is wrong wit this code:compiler says:WRONG ANSWER

#include<stdio.h>
int main()
{
int amount;
float bank_charges = 0.5,initial_bal;
scanf("%d ,%f",&amount,&initial_bal);
//printf("%f",initial_bal);
if(initial_bal>=0)
{
if( ( ( (amount)5 )==0 ) &&( ((float)(amount+bank_charges))<= initial_bal) ) { initial_bal = initial_bal - (amount+bank_charges); printf(".2f",initial_bal);
}
else
printf("%.2f",initial_bal);

}
else
{
	printf("%.2f",initial_bal);
}

return 0;
}

When amount==0 then expected output is initial_blance but your answer is initial_blance-0.5 . So, check your code.

1 Like
//