Computer Science, asked by kushal11146, 1 year ago

Write a Program to input 4 Number and find Maximum Number by just using ternary operators.

Answers

Answered by YUVRAJPADHY
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. }

kushal11146: bhai Madarchod hai kya?
Incredible29: its wrong dear
kushal11146: Sorry
YUVRAJPADHY: its ok
Answered by Incredible29
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 !!

Incredible29: well for more help in comp ... send me the ques. link to my inbox
kushal11146: thank You Very Much sis
Incredible29: mah pleasure ...
Incredible29: well .. i think u r in 9 or 10 ... n i am in 10 .. so no sis
Incredible29: frnds
kushal11146: i am heading too 10th..
kushal11146: am from icse board...u too?
Incredible29: yes .. i will be in 10 by 3rd april .. ICSE board
kushal11146: oh same ....
Anonymous: nice
Similar questions