2.3k views
2 votes
Result ← 1

IF(score1 > 500)
{
result ← result + 1
IF(score2 > 500)
{
result ← result + 1
}
ELSE
{
result ← result + 2
}
}
ELSE
{
result ← result + 5
IF(score2 > 500)
{
result ← result + 1
}
ELSE
{
result ← result - 1
}
}
 
 

 If the value of score1 is 505 and the value of score2 is 250, what will be the value of result after the code segment is executed?

 

If the value of score1 is 350 and the value of score2 is 200, what will be the value of result after the code segment is executed?



User AlexGIS
by
5.3k points

1 Answer

3 votes

Answer:

5

Step-by-step explanation:

The first does not agree with (score1 > 500) so you would solve the 2nd else statement. Therefore when the result is equal to 6 you would subtract the values by 1 in the very else statement. (This is the correct answer)

User Felix Ebert
by
5.6k points