It's not submitting although it's running ,it says wrong answer?plz help

#include<stdio.h>

int main()
{
float account_balance;
int transaction;
scanf("%d%f",&transaction,&account_balance);

if(transaction<=account_balance && transaction%5==0)  
{
    account_balance = account_balance - ((float)transaction+0.50);
    printf("%.2f",account_balance);
}
else if(transaction%5!=0)
{
    printf("%.2f",account_balance);
}
else if(transaction>account_balance){
    printf("%.2f",account_balance);
}
return 0;

}

Change this condition

if(transaction<=account_balance && transaction%5==0)

To this

if(transaction + 0.5 <=account_balance && transaction%5==0)

Otherwise bank account will be negative for withdrawals exceeding by 0.5

1 Like