Computer Science, asked by rafimallickgals, 10 months ago

Rewrite the following condition without using logical operator:-
If(a>b||a>c)
System.out.println(a);

Answers

Answered by Kaustubhmukund
134

Answer:

import java.until.*;

class Xy

{

public static void main(String args[])

{

int a,b;

if(a>b)

System. out.println(a);

if(a>c)

System. out.println(a);

}

}

Answered by qwnerazzuri
10

condition without using logical operator:-

instead of using the logical operator, we can use the ternary operator in its place in this case.

ternary operator :

a>b ? True : False  --  if the condition is true the the true value is printed and if the condition is false then the false value is printed.

By simply making the changes below:

System.out.println( (a>b)? (a>c ? a:c) : ((b>c) ? b:c ));

Similar questions