What will be the value of bonus after the following code is executed? int bonus, sales = 6000; if (sales < 5000) bonus = 200; else if (sales < 7500) bonus = 500; else if (sales < 10000) bonus = 750; else if (sales < 20000) bonus = 1000; else bonus = 1250;

Respuesta :

Answer:

500

Explanation:

When using the conditional statement in programming, as soon as the condition is met, the program returns or prints the block under the condition and stop any further execution of conditions.

From the code above, since sales (6000) is above 5000, the code block under the first condition won't be executed. The second condition fulfills the statement (since sales is less than 7500). Therefore, the code block under this condition will be returned or printed (500 bonus) and the code moves out of the condition block.