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:

where am i missing things can anybody help me plz
#include
#include
using namespace std;
int main() {
// your code goes here
int withdraw;
float totalamt;
cout<<"\nEnter the amount to be withdraw : “;
cin>>withdraw;
cout<<”\nEnter the total amount in your account : “;
cin>>totalamt;
if(totalamt>withdraw && withdraw%5==0)
{
cout<<”\nTransaction completed"<<endl;
totalamt=totalamt-withdraw-0.50;
}
else
{
cout<<“transaction cancled”<<endl;
}
cout<<"Total Balance of your account is : "<<fixed<<setprecision(2)<<totalamt;
return 0;
}