Math, asked by radhikanatraj, 6 months ago

condition for EDL is
.​

Answers

Answered by priyankanair
3

Answer:

Hii

Step-by-step explanation:

The conditional operator is somewhat special in that it consists of both the question mark, ?, and the colon, :. It tells the program to evaluate the expression before the question mark and then, depending on the result, execute either the expression before or after the colon. In the example it is tested if val is smaller than 0, and if this is true, the square root of val multiplied by -1 is taken, otherwise the square root of just val itself.

Beside comparison for the number on the left hand side being smaller than the number on the right hand side, several other operators for comparisons exist. Now follows a complete list of such comparison operators, which can only be applied to expressions that result in numbers, e.g. either simple numbers, numerical variables or numerical results of a calculation, but never to arrays:

== true if left hand side is equal to the right hand side

!= true if left and right hand side are unequal

< true if left side is less than right side

<= true if left side is less or equal to right side

> true if left side is greater than right side

>= true if left side is greater or equal to right side

Please note that using comparisons between floating point numbers may not work as you may expect them to do. This is a result of the finite precision of floating point numbers. Thus, for example, 0.1 and the result of e.g. 0.7 / 7 can have different values, in which case a comparison for equality will fail! Thus comparison for equality should in principle only be used with integer numbers.

All these comparison operators actually do a calculation, resulting in a new number. When you see something like a <= b this evaluates to 1 if the expression is true (i.e. if the value of a is less or equal to the value of b), and otherwise to 0. In the test of the conditional execution operator (i.e. everything before the question mark) it is checked if the result is a non-zero number, which then is taken as true, or if it's zero, which is interpreted as meaning false. Thus instead of an expression with a comparison operator the test part could also consist of just a simple number and what is going to be executed of the two alternatives after the question mark depends on the value of this number: if it is non-zero the first alternative is used, but if it is zero the second. Thus it would be valid to write:

exp_of_val = val ? exp( val ) : 1;

Similar questions