Computer Applications
Rewrite the following using ternary operator.
if(p>5000)
d = p*5/100;
else
d = 2*p/100;
Java Operators
141 Likes
Answer
d = p > 5000 ? p * 5 / 100 : 2 * p / 100;
Answered By
83 Likes
Related Questions
Evaluate the following expressions, if the values of the variables are a = 2, b = 3 and c = 3
i. a - (b++) * (--c)
ii. a * (++b) %c
If a = 5, b = 9, calculate the value of:
a += a++ - ++b + aGive the output of the program snippet.
int a = 10, b =12; if(a>=10) a++; else ++b; System.out.println(" a = " + a + " and b = " +b);
Rewrite the following using ternary operator.
if(income<=100000) tax = 0; else tax = (0.1*income);