Output Questions for Class 10 ICSE Computer Applications

Rewrite the following using ternary operator:

if(a > b)
{
    if (a > c)
        g = a;
    else
        g = c;
}
else if (b > c)
    g = b;
else
    g = c;

Java

Java Operators

197 Likes

Answer

g = a > b ? a > c ? a : c : b > c ? b : c;

Answered By

108 Likes