#define MIN(x,y) ((x<y)?x:y)
#define MAX(x,y) ((x>y)?x:y)
You can use one of the Math.max() methods, or the ternary operator, that is, one of the following: Math.max(a, b) a > b ? a : b
Compare the first two numbers with the ternary operator. Store the result in a temporary variable. Compare the temporary variable with the third number, again using the ternary operator.
Conditional Operator- Its the only ternary operator in c/c++.- Its syntax is-(condition)?statement1:statement2;-Shruti Jain
You can use the ternary operator, in an expression such as: result = a > b ? a : b; This is equivalent to: if (a > b) result = a; else result = b;
Ternary operator
write a c program to fine largest/smallest of 3no (using ?:ternary operator/conditional operator)
1. Member-of operator (.) 2. Pointer-to-member-of operator (.*) 3. Ternary condition operator (?:) 4. Scope resolution operator (::) 5. sizeof operator 6. typeid operator
The conditional operator is also known as ternary operator. It is called ternary operator because it takes three arguments. The conditional operator evaluates an expression returning a value if that expression is true and different one if the expression is evaluated as false.Syntax:condition ? result1 : result2If the condition is true, result1 is returned else result2 is returned.
Compare two numbers, a and b. If a is greater than b then return a, otherwise return b. In C, we can implement this algorithm using the ternary operator (?:), as follows: return a>b?a:b;
The only "special" operators in C++ are those that cannot be overloaded. That is; the dot member operator (.), pointer to member operator (.*), ternary conditional operator (:?), scope resolution operator (::), sizeof() and typeof().
A ternary operator takes 3 operands. The only one I can think of in C# or C is the"? :" operator: ? : For example:Console.Write(1==2 ? "Huh?" : "Impossible"); //Impossible is printed
Selection constructs in C++if...elseswitch/caseconditional ternary operator (?:)