help me to solve the error.

Link to updated solution? The one you posted in help me to solve the error. - #19 by geeky_boy gives no output for that test input on my machine. (Edit: though it does give the correct output on Codechef. Interesting.)

Edit:

if it’s this one, consider the test input:

5 5.49

Can someone show me what mistake did I make here?
#include<bits/stdc++.h>
using namespace std;
int main()
{
int x;
double y;
cin>>x;
cin>>y;

if((x%5==0) && (x+0.5<y))
{
double bal=y-(x+0.5);
cout<<fixed<<setprecision(2)<<bal;
}
else{
    cout<<fixed<<setprecision(2)<<y;
}

return 0;
}

#include<bits/stdc++.h>

using namespace std;

int main()

{

int x;

double y;

cin>>x;

cin>>y;



if((x%5==0) && (x+0.5<=y))

{

double bal=y-(x+0.5);

cout<<fixed<<setprecision(2)<<bal;

}

else{

    cout<<fixed<<setprecision(2)<<y;

}

return 0;

}
Now? Changed the condition

Should work now, I think.

1 Like

#include
using namespace std;
int main() {
int x;
float y;
cin>>x>>y;
if(x % 5 == 0 && x<=y -0.5)
y=y-x-0.5;
if(x % 5 !== 0 && x<=y -0.5)
y=y;
else
y=y;
cout<<y;
return 0;
}
what is wrong in this code?

Please either format your code or (better!) link to your submission - the forum software has mangled it and it won’t compile! :slight_smile: