Computer Science, asked by AryaSrivastava, 4 days ago

Rewrite the program segment using if else construct. [2] comm = (sale > 5000)?sale * 10/100 : 0;​

Answers

Answered by BrainlyProgrammer
5

Answer:

if(sale>5000)

comm=sale*10/100;

else

comm=0;

Explanation:

A sample ternary operator is given below

boolean a=(2>3)?true:false;

Here if 2>3 == true then a will store true otherwise if the condition is false a will store false.

Similarly in the above question,

comm=(sale>5000)?sale*10/100:0;

Compiler will assign sale*10/100 only if sale is greater than 5000 otherwise will assign 0.

Similar questions