Nested If Statement Execution
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
Question Leaderboard
| Rank | |||||
|---|---|---|---|---|---|
| #1 | sgarv2513 | 1 | 2 | 0m 00s | 90 |
| #2 | hitrishabhatia | 1 | 3 | 0m 00s | 80 |
| #3 | kazvin.tjakradinata | 1 | 1 | 0m 25s | 75 |
| #4 | y.seong2027 | 1 | 1 | 0m 43s | 57 |
| #5 | namansoin000 | 1 | 1 | 0m 51s | 49 |
| #6 | psak12 | 1 | 1 | 0m 54s | 46 |
| #7 | Pelisx | 1 | 1 | 0m 59s | 41 |
| #8 | geethasailaja | 1 | 1 | 5m 43s | -243 |
| #9 | suhanakochhar006 | 1 | 3 | 16m 45s | -925 |
| #10 | bommasam000 | 2 | 4 | 32m 07s | -1,747 |
Items per page:
10
1 – 10 of 10
APFIVE