c) Re-write the following code snippet using ternary operator:
if (a>b)
if (a>c)
m=a
else
m=c;
else
if(b>c)
m=b
else m=c;
Answers
Answered by
1
Question: Convert if-else to ternary operator
Answer:
m=(a>b)? (a>c)? a : c) : (b>c)? b : c;
Answered by
1
Answer:-
Using ternary operator, we can write like this,
m=(a>b)?((a>c)?a:c):((b>c)?b:c);
Similar questions
Chemistry,
2 months ago
Science,
5 months ago
Math,
5 months ago
Computer Science,
10 months ago
Economy,
10 months ago
Political Science,
10 months ago