C++ class question

Feb 26, 2019 at 3:10am
How does the mathematical expression (3 ≤ n)∧(n ≤ 7) translate to C++?
Feb 26, 2019 at 4:48am
bool result = ((3 <= n) && !(n <= 7)) || (!(3 <= n) && (n <= 7));

result is true when (3 <= n) is true and (n <= 7) is false
result is true when (3 <= n) is false and (n <= 7) is true

result is false when (3 <= n) is false and (n <= 7) is false
result is false when (3 <= n) is true and (n <= 7) is true

Not sure if that's what you wanted, but that's my best guess.
Feb 26, 2019 at 8:51am
I have to ask: What is the ?

Wiki says "logical and". If so, then the expression states that n should be between 3 and 7.
(3 <= n) && (n <= 7)
Topic archived. No new replies allowed.