1.

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

Answer»

if(sale>5000)comm=sale*10/100;elsecomm=0;Explanation:A SAMPLE ternary OPERATOR is given belowboolean 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.



Discussion

No Comment Found