Lab 3
AIM: Write a program in Java to find a maximum of three numbers using conditional operator.MaxOutOfThree.java
import java.util.Scanner; class MaxOutOfThree { public static void main(String arg[]) { int max,a,b,c; Scanner sc=new Scanner(System.in); System.out.print("Enter 1st Number: "); a=sc.nextInt(); System.out.print("Enter 2nd Number: "); b=sc.nextInt(); System.out.print("Enter 3rd Number: "); c=sc.nextInt(); max=a>b?(a>c?a:c):(b>c?b:c); System.out.println("\nMaximum number is "+max); } }
Output
Maximum number out of three numbers in java by practical server |
Note: Please Try to Yourself
Happy Coding :)
0 Comments
Post a Comment