97.4k views
0 votes
What would be the value of bonus after the following statements are executed?

int bonus, sales = 85000;
char dept = 'S';
if (sales > 100000)
if (dept == 'R') bonus = 2000;
else bonus = 1500;
else if (sales > 75000)
if (dept == 'R') bonus = 1250;
else bonus = 1000;
else bonus = 0;

User Leenasn
by
6.7k points

1 Answer

3 votes

Answer:

1000

Step-by-step explanation:

first it will check for outer if (if (sales > 100000) ) as it is false it will go to else if(else if (sales > 75000) ) part. as this condition true, it will check dept and if(dept=='R') is false corresponding else part will be executed .

User Paul Lysak
by
6.1k points