what is wrong in my coding

#include <stdio.h>

int main(void) {
int n;
float x;
scanf("%d",&n);
scanf("%f",&x);
if(n%5!=0)
printf("%f",x);
else if(n>x)
printf("%f",x);
else
printf("%f",x-n-0.5);
// your code goes here
return 0;
}

Very first, please provide ideone link to your solution or put your code with proper indentation. Secondly, you didn’t mention the reference of the question you wanted answer of. Third, the question however is ATM. The mistake is you are not checking the condition that withdraw can be done only when (the amount to be withdrawn +0.5)<= account balance. You are missing this condition.

Ex: consider this test case:

10 10.2

For this, output will be 10.20 but your code gives -0.30 because you allowed the transaction as per your code. Also, put

printf("%.2f",amt);

as you are supposed to print upto 2 decimal digit precision. Not putting it will not give wrong answer but as the question said , it should be this.

Hope it helps…