| preferred AP College board partner for AP classes
medium Solved by 14 students
Nested If Statement Execution
< Prev
Next >

What values are stored in x and y after execution of the following program segment?

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 = 10 y = 15

B

x = 10 y = 5

C

x = 10 y = 10

D

x = 8 y = 5

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

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Time
Score
#1sgarv251312 0m 00s 90
#2hitrishabhatia13 0m 00s 80
#3kazvin.tjakradinata11 0m 25s 75
#4y.seong202711 0m 43s 57
#5namansoin00011 0m 51s 49
#6psak1211 0m 54s 46
#7Pelisx11 0m 59s 41
#8geethasailaja11 5m 43s -243
#9suhanakochhar00613 16m 45s -925
#10bommasam00024 32m 07s -1,747
Items per page:
10
1 – 10 of 10

AI Tutor

How can I help?

APFIVE © 2020.
Email: [email protected]|Privacy Policy