Plsss, answer this
Rewrite the following codes using only Ternary operators.
Attachments:
Answers
Answered by
3
Write the following code using ternary operator.
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
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