R = (A > B && A > C) ? A : (B > C) ? B : C; // parentheses not necessary - for clarity only
max = a > b ? a : b; max = max > c ? max : c;
Ternary operator
write a c program to fine largest/smallest of 3no (using ?:ternary operator/conditional operator)
// assume you want the find the largest of ints a,b,c: int max = (a>b&&a>c?a:b>c?b:c);
int max (int a, int b) { return a<b?b:a; } int max3 (int a, int b, int c) { return max (max (a, b), c); }
0 1 and 2
All numbers - integers as well as non-integers - are combined using different mathematical operations. Some operators are binary: that is, they combine two numbers to produce a third; some are ternary (combine 3 to produce a fourth) and so on.The set of integers is closed under some operations: common examples are addition, subtraction, multiplication, exponentiation. But not all operators are: division, for example.
Maybe your speaking a variable that contains a ternary operators such as:
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().
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.
The answer depends on what you are converting from: binary, ternary, octal, hexadecimal ...
it is used in = TERNARY FORM .$.