Computer Science, asked by vinya3113, 1 month ago


integer x = 5, y = 4, Z
Z= x>y? X-y x + y
print z​

Answers

Answered by Oreki
26

\text{\large\bf Given Snippet}

   \texttt{Integer x = 5, y = 4, z;}\\\texttt{z = (x > y) ? x - y : x + y;}\\\texttt{System.out.println(z);}

\text{\large\bf Outpu\symbol{116}}

   \textsf{As, x \textit{is more than} y,}\\\texttt{\:\: z = x - y}\\\texttt{\:\: z = 5 - 4}\\\texttt{\:\: z = 1}\\\textsf{\textbf{Outpu\symbol{116} :} 1}

Answered by vinod04jangid
0

Answer:

Z = 1

Explanation:

Given:- x=5, y=4

Z = x > y? x-y: x+y

To Find:- Z.

Solution:-  x = 5, y = 4

Here, ternary operator is being used.

So, if the condition is true the expression after the "?" is executed.

As 5 > 4 = true.

So, x - y = 5 - 4 = 1

#SPJ2

Similar questions