Here is what I have so far but if the number is negative then it displays the wrong answer. I know there is probably an easier way to figure this out, but it has been forever since I have worked with C++ and I can not figure it out
I have the user input 3 numbers:
Code:
if (x-y < y-z && x-y < x-z)
{
cout << "The two closest numbers are: "<< x << " & " << y << endl;
}
else if (y-z < x-y && y-z < x-z)
{
cout << "The two closest numbers are: "<< y << " & " << z << endl;
}
else if (x-z < x-y && x-z < y-z)
{
cout << "The two closest numbers are: "<< x << " & " << z << endl;
}
I guess my question is, is there some sort of loop I can do here or a different way to subtract the numbers( 10-6 instead of 6-10)?