why isNT codechef accepting my code, it works fine on my pc but yours gives wrong

code is for ATM in practice->easy section
#include<stdio.h>
#include<stdlib.h>
main()
{
float z,y;
int x;
scanf("%d%f",&x,&y);
if (x>y||(x%5)!=0)
printf("%f",y);
else
{
z=y-x-0.50;
printf("%f",z);
}

return 0;
}

All these points are leading to wrong answer:

  1. The condition if(x > y||(x%5)!=0) is not correct.

The correction is: if(x > y-0.5)||(x%5)!=0)

  1. The problem statement states that the answer is to be printed upto 2 decimal places, i.e., it must contain only 2 digits after the decimal point.

for that use printf as printf(".2f",y);** and **printf(".2f",z);

this will print only 2 digits after the decimal.



If you still get wrong answer, just comment below, I will help you out.

Happy Coding

Cheers!

1 Like
//