Problem in submitting solution of Practice and Learn (ATM Problem)

Its my first code on CodeChef so…

ATM problem link: https://www.codechef.com/problems/HS08TEST

#include <stdio.h>

int main(void) {
int a,c;
float b, d;
scanf("%d %f",&a,&b);
if((a%5==0)&&(a+0.5<=b)&&(2000>=a>0)&&(0<b<=2000))
{
c=(b-a);
d=(c-0.5);
printf("%f",d);

``````}
else
{
printf("%f",b);
}
return 0;
``````

}

this is my code and I give all the possible inputs to it and this code is giving me the perfect output which is mentioned in the documentation of the problem but when i submitted the code its showing wrong answer what to do .Please help me to find whats i am missing in this code

This is wrong here .
c is an integer and but answer of b-a can be a decimal

Consider this test case

5 5.50
c = 0 in this but it should be 0.5

``````#include <stdio.h>

int main(void) {
int a, c;
float b, d;
scanf("%d %f", &a, &b);
if ((a % 5 == 0) && (a + 0.5 <= b) && (2000 >= a > 0) && (0 < b <= 2000))
{
// use d instead of c
d = (b - a);
d = (d - 0.5);
printf("%.2f", d);
}
else
{
printf("%.2f", b);
}
return 0;
}
``````
2 Likes

Thank you bhiya i missed it

1 Like