Computer Science, asked by udevi4470, 9 months ago

Ternary
operatori
(a) int a = 6;
int c=a>= 5? 41:31
system.out. println (c)
(b) int a = 5;
int d = a % 2 ==0? 21:35
System, out println (d)

(d) int a=7
int p=a+1<6? a++:++a
System.out.println (p)​

Answers

Answered by anishasa
2

Answer:

Ternary Operator

Syntax:

number = (expression) ? expressionTrue : expressinFalse;

If the Expression condition is true, Expression true statement will get executed Otherwise the Expression False statement gets executed

(a) c = 6 > = 5 This statement is true

So the ExpressionTrue gets executed

Answer:

41

(b) d = 5 % 2 == 0 This Statement is false

Therefore the ExpressionFalse executes

Answer:

35

p = 7 + 1 < 6 This statement is false

So ++a pre increment operator gets incremented by 1 , a = 7 ++a ----> 8

Answer:

8

Similar questions