Computer Science, asked by ashwin1657, 6 months ago

c. Write a program to take two values from user using scanner class and check
which number is greater number using ternary operator ​

Answers

Answered by suryasingh55
1

Answer:

In this Program, we have used the ternary operator twice to compare the three numbers, however you can compare all three numbers in one statement using ternary operator like this:

result = num3 > (num1>num2 ? num1:num2) ? num3:((num1>num2) ? num1:num2);

However if you are finding it difficult to understand then use it like I have shown in the example below:

Similar questions