Atm question ..whats wrong with my code works on other editors

using namespace std;
 
int main()
{
int a;
float b;
cin>>a>>b;
if(b>a)
{
  if(a%5==0)
   {
   	float tot= b-float(a)-0.50;
   	
   	printf("%.2f",tot);
   }
  else 
  printf("%.2f",b);	
}
else
printf("%.2f",b);
return 0;
}```

it is working…what error are you talking about?

Actually

it should not work for
a=5 b=5.40

but it is giving AC on submission…

Edit : I was submitting on this one by mistake XD https://www.codechef.com/problems/ATM

i dont sir it says wrong answer

I see that you’re new here :slight_smile: , Hello!

Please provide a link to the question and format the code ( three backticks : ``` , before and after code snippet will do the trick )

#include<bits/stdc++.h>
using namespace std;

int main()
{
int a;
float b;
cin>>a>>b;
if(b>a)
{
if(a%5==0)
{
float tot= b-float(a)-0.50;
printf("%.2f",tot);

}
else
printf("%.2f",b);
}
else
printf("%.2f",b);
return 0;
}

Doesn’t that code look better already ? One more tip , use indentation wherever possible so that the code looks clear and not unnecessarily obfuscated

Coming back to the question at hand , it’s been a long long time since I attempted this question so I feel this case might produce wrong output for your code ?

10 10.01

I think the code will produce a negative output , check why :wink: ?

4 Likes

I just read your comment , It’s pretty surprising that it gives AC xD

1 Like

thank you sir it worked for me :grin: overcome the negative output

1 Like