import java.util.Scanner;
class prog7
{
public static void main(String[] args)
{
int a, b, c, d;
Scanner s = new Scanner(System.in);
System.out.println("Enter all three numbers:");
a = s.nextInt();
b = s.nextInt();
c = s.nextInt();
d = c > (a > b ? a : b) ? c : ((a > b) ? a : b);
System.out.println("Largest Number:"+d);
}
}
/*suppose a=10 , b=20 , c=30
then the above code will check first 10>20 ? 10 :20,
here the condition is false so answer will be 20,
now 30>20 ? 30:20, in this case the value of c is greater and the condition is true,
so it will print 30 as a largest number*/
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.