2) Rewrite the following using ternary:
if(sale->25000)
dis =5000;
else if(sale>15000)
dis = 3000;
else dis=1000:
Answers
Answered by
0
Answer:
(sale>25000)?dis=5000:((sale>15000)?dis=3000:dis=1000);
Explanation:
Answered by
1
Question:-
- Rewrite the following code using ternary operator.
Solution:-
Given code,
if(sale>25000)
dis=5000;
else if(sale>15000)
dis=3000;
else
dis=1000;
The given code can be written using ternary operator as,
dis=(sale>25000)?5000:(sale>15000)?3000:1000;
Similar questions