ATM problem, second easiest question on this site, where on gods green earth am I going wrong?!?!

,

So below is my code, there’s a test case in there somewhere which invalidates my code, but I can’t see it, and it’s driving me nuts.

#include “stdio.h”

int main()
{
int x = 0;
float y=0;
float charge = 0.5;

scanf("%d%f",&x,&y);
if ((x>y) || (x % 5 != 0) || (x>2000) || (x<1) || (y<0) || (y>2000))

{

printf("%0.2f",y) ;
return 0;

}

float result = (y-x-charge);
printf("%0.2f",result);
return 0;

}

Check your code for the input:

1000 1000.3

You are missing some check conditions in your code. Read the question carefully once again and try debugging. The correct output should be 1000.299988

1 Like