Sunday, 12 March 2023

4. Write a java program to scan 3 integer values from the command line argument and display the maximum number using conditional operator.

 



class Program4
{
    public static void main(String args[])
    {
        int a = Integer.parseInt(args[0]);
        int b = Integer.parseInt(args[1]);
        int c = Integer.parseInt(args[2]);
        int max;
       
        max = (a>b)? ((a>c)? a: c) : ((b>c)? b : c);
       
        System.out.println("Maximum number is: " + max);
       
    }
}


No comments:

Post a Comment

python programs

1. sum of two number