Computer Science, asked by izabelJustin, 5 months ago

Plsss, answer this
Rewrite the following codes using only Ternary operators. ​

Attachments:

Answers

Answered by anindyaadhikari13
3

\star\:\:\:\sf\large\underline\blue{Question:-}

Write the following code using ternary operator.

\star\:\:\:\sf\large\underline\blue{Answer:-}

Given code,

int x, y;

if(x>5)

y=x+2;

else

y=x-2;

This can be written using ternary operator as,

int x, y;

y=(x>5)?x+2:x-2;

Answered by Ash34567
2

Answer:

Given code,

int x, y;

if(x>5)

y=x+2;

else

y=x-2;

This can be written using ternary operator as,

int x, y;

y=(x>5)?x+2:x-2;

Explanation:

Hope this helps you buddy.....

Similar questions