the judge is saying this is wrong ! i can’t find the error. please help ! thanks.

#include <iostream>
#include <iomanip>
using namespace std;

int main()
{int x;
float y;

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

print x also,it may be work

its giving wrong answer for 3 120.00…try setprecision(6)…

Try removing ‘=’ …x<y-0.5

check out this link:

std::fixed is-

ios_base& fixed (ios_base& str);

It sets the floatfield format flag for the str stream to fixed.

When floatfield is set to fixed, floating-point values are written using fixed-point notation: the value is represented with exactly as many digits in the decimal part as specified by the precision field (precision) and with no exponent part.

you can write-

cout << setiosflags(ios::fixed | ios::showpoint)
<< setprecision(2)
<< y;

for more details refer to-

1 Like

i have resolved this partially. It worked if i add cout<<fixed; before the orignal cout statment.but I have no idea how!

no output needs only y-balance. x is withdraw amt is not needed

no ,I rechecked output is 120 only for 3.set precision is way too high . the question only wants 2 digits of precision.