?

Free Version
Moderate

# If Else Statements

APCSP-QGEKDN

Which of the following code segments will multiply x by 2 if it’s even, multiply x by -2 if it’s odd, and add 1 to x if it’s zero?

A
IF (x MOD 2 = 0)
{
IF (x = 0)
{x ← x + 1}

ELSE
{x ← x * 2}
}

ELSE
{x ← x * -2}

B
IF (x = 0)
{x ← x + 1}

IF (x MOD 2 = 1)
{x ← x * -2}

IF (x MOD 2 = 0)
{x ← x * 2}

C
IF (x = 0)
{x ← x + 1}

IF (x MOD 2 = 0) AND (NOT (x = 0))
{x ← x * 2}

IF (x MOD 2 = 1)
{x ← x * -2}

D
IF (x = 0)
{x ← x + 1}

IF (x MOD 2 = 1)
{x ← x * -2}

ELSE
{x ← x * 2}