Write a Program to input 4 Number and find Maximum Number by just using ternary operators.
Answers
Answered by
2
1. import java.util.Scanner ;
2. public class Largest_Tern
3. {
4. public static void ma
5. {
6. int a, b, c, d ;
7. Scanner s = new
8. System . out .printl
9. a = s. nextInt () ;
10. b = s. nextInt () ;
11. c = s. nextInt () ;
12. d = c > (a > b ?
13. System . out .printl
14. }
15. }
2. public class Largest_Tern
3. {
4. public static void ma
5. {
6. int a, b, c, d ;
7. Scanner s = new
8. System . out .printl
9. a = s. nextInt () ;
10. b = s. nextInt () ;
11. c = s. nextInt () ;
12. d = c > (a > b ?
13. System . out .printl
14. }
15. }
kushal11146:
bhai Madarchod hai kya?
Answered by
10
Hello Friend ,
Here is your answer !!
import java.util.*
public class Max
{
public static void main ( String args [] )
{
Scanner in = new Scanner ( System.in ) ;
System.out.println ( " Enter 4 no. : " ) ;
int a = in.nextInt () ;
int b = in.nextInt () ;
int c = in.nextInt () ;
int d = in.nextInt () ;
int M = ( a > b )? ( ( a > c ) ? a : c ) : ( ( b > c ) ? b : c ) ;
int MM = ( M > d ) ? M : d ;
System.out.println ( " The largest number is : " + MM ) ;
}
}
Hope it helps you !!
Here is your answer !!
import java.util.*
public class Max
{
public static void main ( String args [] )
{
Scanner in = new Scanner ( System.in ) ;
System.out.println ( " Enter 4 no. : " ) ;
int a = in.nextInt () ;
int b = in.nextInt () ;
int c = in.nextInt () ;
int d = in.nextInt () ;
int M = ( a > b )? ( ( a > c ) ? a : c ) : ( ( b > c ) ? b : c ) ;
int MM = ( M > d ) ? M : d ;
System.out.println ( " The largest number is : " + MM ) ;
}
}
Hope it helps you !!
Similar questions