Answers:
/* The program to find the largest number using Ternary Operators */
public class LargestNumber {
public static void main(String args[]) {
int num1, num2, largestnum;
num1= 10;
num2= 60;
if(num1!=num2) {
largestnum= num1>num2?num1:num2;
System.out.println("The Largest number is " + largestnum);
}
else {
System.out.println("Both numbers are equal");
}
}
}
public class LarNum {
public static void main(String args[]) {
int a, b, larnum;
a= 10;
b= 60;
if(a!=b) {
larnum= a>b?a:b;
System.out.println("The Largest number is " + larnum);
}
else {
System.out.println("Both numbers are equal");
}
}
}
public static void main(String args[]) {
int a, b, larnum;
a= 10;
b= 60;
if(a!=b) {
larnum= a>b?a:b;
System.out.println("The Largest number is " + larnum);
}
else {
System.out.println("Both numbers are equal");
}
}
}
Login to add comment