You are here: Home / Topics / Conditional Operators Examples 2 in Java

Conditional Operators Examples 2 in Java

Filed under: Java on 2023-08-11 19:28:21

// Program to find the Largest of three given numbers using Conditional Operator

class MaxOf3ConditionalOperator
{
public static void main( String args[ ] )
{
 int a, b, c, max = 0;

 a = 20;
 b = 30;
 c = 45;

    max = ((a>b) ? ((a>c) ? a : c ) : ((b>c) ? b : c ));

 System.out.println( " The LARGEST Number is = " + max );
}
}


Output:

 The LARGEST Number is = 45

About Author:
V
Vinay Kumar     View Profile
Hi, I am using MCQ Buddy. I love to share content on this website.