In this we are going to see a basic program to find greater number using ternary operator in Java Programming Language.
import java.util.Scanner;
public class Test {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter 2 integers:");
int a = sc.nextInt();
int b = sc.nextInt();
int max = (a > b) ? a : b;
System.out.println("The Bigger number is " + max);
}
}
// Coded by Saahil
#ENJOY CODING
Post a Comment
FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP