Choosing how to earn college credit? CLEP vs AP guide
| 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 - 90
#2hitrishabhatia13 - 80
#3Potter1611 0m 20s 80
#4kazvin.tjakradinata11 0m 25s 75
#5barkern19511 0m 29s 71
#6y.seong202711 0m 43s 57
#7namansoin00011 0m 51s 49
#8psak1211 0m 54s 46
#9Pelisx11 0m 59s 41
#10busemagngr11 1m 13s 27
Items per page:
10
1 – 10 of 17
No comments yet. Be the first to comment!

AI Tutor

How can I help?

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