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? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 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?

10th Mar 2017, 3:33 PM
Shuvam Pal
Shuvam Pal - avatar
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
10th Mar 2017, 3:38 PM
เคฆเฅ‡เคตเฅ‡เค‚เคฆเฅเคฐ เคฎเคนเคพเคœเคจ (Devender)
เคฆเฅ‡เคตเฅ‡เค‚เคฆเฅเคฐ เคฎเคนเคพเคœเคจ (Devender) - avatar
+ 1
You must write "x<=y && y<=z". [EDIT:] && is the boolean operator that means "and".
10th Mar 2017, 3:39 PM
รlvaro
+ 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.
10th Mar 2017, 4:05 PM
เคฆเฅ‡เคตเฅ‡เค‚เคฆเฅเคฐ เคฎเคนเคพเคœเคจ (Devender)
เคฆเฅ‡เคตเฅ‡เค‚เคฆเฅเคฐ เคฎเคนเคพเคœเคจ (Devender) - avatar
+ 1
No dear these cannot be use in switch clause as it evaluate expression only against fixed values
10th Mar 2017, 4:07 PM
เคฆเฅ‡เคตเฅ‡เค‚เคฆเฅเคฐ เคฎเคนเคพเคœเคจ (Devender)
เคฆเฅ‡เคตเฅ‡เค‚เคฆเฅเคฐ เคฎเคนเคพเคœเคจ (Devender) - avatar
0
Let me implement by this
10th Mar 2017, 3:47 PM
Shuvam Pal
Shuvam Pal - avatar
0
By the way can u explain how & & helping it out?
10th Mar 2017, 3:47 PM
Shuvam Pal
Shuvam Pal - avatar
0
It work thank you
10th Mar 2017, 3:58 PM
Shuvam Pal
Shuvam Pal - avatar
0
Can i use those relation operators with switch cases?
10th Mar 2017, 3:58 PM
Shuvam Pal
Shuvam Pal - avatar