27.0k views
5 votes
Var amount = 100;

var discount = 0;

if(amount>50)
discount = 0.1;
else if( amount > 75)
discount =0.15;
else if( amount>100)
discount =0.2;
else
discount =0.25;

What is the value of discount?

0

0.1

0.15

0.2

1 Answer

3 votes

Answer:

0.1

Step-by-step explanation:

The value of amount is 100.So in the if-else-if ladder first condition in if will be checked since the amount is greater than 50 so the value of discount will become 0.1 and the execution of if else if ladder will be finish.The compiler will not be executing elseif or else.So the answer to this question is 0.1.

User Aceofbassgreg
by
5.8k points