Rewrite the following using ternary operator.
If(p>4000)
d = p*5/100;
else
d = 2*p/10;
Answers
Answered by
4
Question:-
Rewrite the following code using ternary operator.
Answer:-
Given code snippet,
if(p>4000)
d=p*5/100;
else
d=2*p/100
Using ternary operator,we can write this,
d=(p>4000)?p*5/100:2*p/100;
Similar questions