Are you taking CLEP classes? Try clep.ai
| preferred AP College board partner for AP classes
medium Solved by 16 students

Nested If Statement Execution

Mark
< Prev
Next >

What are the values of x and y after the following code segment is executed?

int x = 10, y = 5;
if (x > 0)
{
    if (x < 20)
    {
        y += x;
        if (y > 15)
            x /= 2;
    }
    else
        y = x - y;
}
else
    x *= -1;
A

x = 8 y = 5

B

x = 10 y = 5

C

x = 10 y = 10

D

x = 10 y = 15

Hint
Did You Know?
Explain Why
Explain All Answers
Check Answer
Show Correct Answer
Report Question

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Total Time
Score
#1sgarv251312 0m 00s 90
#2Potter1611 0m 20s 80
#3hitrishabhatia13 0m 00s 80
#4kazvin.tjakradinata11 0m 25s 75
#5y.seong202711 0m 43s 57
#6namansoin00011 0m 51s 49
#7psak1211 0m 54s 46
#8Pelisx11 0m 59s 41
#9busemagngr11 1m 13s 27
#10pandasiteitei11 2m 24s -44
Items per page:
10
1 – 10 of 16

AI Tutor

How can I help?

APFIVE © 2020.
Email: apfive@apfive.org|Privacy Policy|