WAP to show the use of ternary operator.
2 years ago
OOP Java
Compile code:
public class Ternaryoperator
{
public static void main(String args[])
{
int x, y;
x = 20;
y = (x == 1) ? 61: 90;
System.out.println("Value of y is: " + y);
y = (x == 20) ? 61: 90;
System.out.println("Value of y is: " + y);
}
}
Output:
Dipti KC
Jan 8, 2023