+ 2
How to Find greatest no where a=5; b=7;c=10 using ternery operators...
2 ответов
+ 5
int a=7;
int b=10;
int c=5;
int x = 0;
using if-else :-
if(a>b)
{
if(a>c)
x=a;
else
x=c;
}
else
{
if(b>c)
x=b;
else
x=c;
}
using ternary :-
x = (a>b)?(a>c)?a:c:(b>c)?b:c;
+ 2
Use nested ternary operators.
x = (a > b) ? ( (a > c) ? a : c ) : ( (b > c) ? b : c )