Issues with conditional operators and decimals

Hi.

I'm new here and to C++. The code is correct as long as the value entered is whole but if the value is a decimal, then it doesn't work correctly. Any idea what I am missing? Thanks.


int x, y;
cout << "Enter a value for x: ";
cin >> x;
cout << "Enter a value for y: ";
cin >> y;
cout << (((2 * x + 3 * y) > 15) ? "yes" : "no") << endl;

Change int to double and you should be good.
Non-integers means floating-point numbers in computing terms. I suggest reading up on C++ data types.
Topic archived. No new replies allowed.