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
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
English,
2 months ago
Computer Science,
2 months ago
Social Sciences,
2 months ago
Social Sciences,
5 months ago
English,
9 months ago