- 1

# In c++ it show compression like x<=y<=z hv no mathematical meaning, what do i do to implement this type of conditions by if?

8 Answers

+ 1

Dear Shuvam,
Expression x<=y<=z implies that x<=y and y<=z, thus it can be implemented in following manner
if (x<=y && y<=z){
//your code
}
I think this will help

+ 1

You must write "x<=y && y<=z".
[EDIT:] && is the boolean operator that means "and".

+ 1

The above expression is mathematically okay. But when it comes to programming, such expressions need to be broken into binary expressions and combined using logical operators.
Let us examine it
x<=y<=z say that x is greater than or equals to y and y is greater than or equals to z. Here we get two expressions
x <= y
y <= z
Now we need to combine them. Since both have to be evaluated as true to get processed, we will perform and operation on them and in C++ it is done by && operator.

+ 1

No dear these cannot be use in switch clause as it evaluate expression only against fixed values

0

Let me implement by this

0

By the way can u explain how & & helping it out?

0

It work thank you

0

Can i use those relation operators with switch cases?