Write a program to accept 5 numbers and print the largest number by conditional operator in Java bluej
Answers
Answered by
0
Answer:
Input : 10, 20
Output :
Largest number between two numbers (10, 20) is: 20
Input : 25 75 55 15
Output :
Largest number among four numbers (25, 75, 55, 15) is: 75
if answer is wrong please report and give comment
Answered by
2
This program finds the largest of three numbers using ternary operator. Before going through the program, lets understand what is a ternary Operator:
Ternary operator evaluates a boolean expression and assign the value based on the result.
variable num = (expression) ? value if true : value if false
If the expression results true then the first value before the colon (:) is assigned to the variable num else the second value is assigned to the num.
Similar questions