Computer Science, asked by subrata2394, 1 year ago

Write a program in java to find greatest of two number using ternary operator

Answers

Answered by neelbhatkar3
3

import java.util.*;

public class ternary

{

public static void main(String args[])

{

Scanner sc=new Scanner(System.in);

int a, b;

System.out.println("enter the first number");

a=sc.nextInt();

System.out.println("enter the second number");

b=sc.nextInt();

if(a>b)

System.out.println(" the first number:"+" "+a+" "+"is the greatest  of the two numbers");

if(a<b)

System.out.println("the second number:"+" "+b+" "+"is the greatest of the two numbers");

}

}

Similar questions
Math, 6 months ago