Hi there,
I've been doing a bit of a google search and I'm getting a little confused with how to work an if statement based on a range of values.
To put simply....
Given that:
double x;
What would be the best way to print something to screen if:
(14.8 ≤ x ≤ 15) then cout << "YES";
or
(14.6 ≤ x < 14) then cout << "NO";
Note the 'less than and equal to signs'.
Any advice / directions would be appreciated.
Thanks.
Last edited on
1 2 3 4 5 6 7 8 9
|
if (x >= 14.8 && x <= 15) //&& is a logical "AND"
{
std::cout << "YES";
}
if (x >= 14.6 && x <= 15)
{
std::cout << "NO;
}
|
Last edited on
Thanks Sasauke!
I should have know this..... Appreciate the response!
Last edited on