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

Nested If Statement Execution

< 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
Mark for review

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Total 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
#8pandasiteitei11 2m 24s -44
#9meromaroseif12 3m 33s -123
#10geethasailaja11 5m 43s -243
Items per page:
10
1 – 10 of 13
No comments yet. Be the first to comment!

AI Tutor

How can I help?

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