i am unable to find the error in this code.please help me

include

using namespace std;
int main()
{
double x,y,o,mod;
cin>>x;
cin>>y;

mod=y;
while(mod>=x)
{mod = mod-x;
}
//	cout<<"mod is"<<mod;

if(mod==0.00)
{
	if(y>x)
	{ //cout<<x<<" "<<y;
	
	o= ((y-x)-0.50);
	//cout<<o;
	}
	else
	{
	o=y;
	}
	
}
else
{
	o=y;
		}
		cout<<o;

return 0;

}

I found your bug… You are checking whether y x is true but you need to check whether x 5 is true.


Here is a testcase where you fail:
34 68


Your Code Output:
33.5


My Code Output:
68.0


Here is a link to my AC Code

Please mark this answer as accepted if you found this answer useful