Which of the sets of statements below will add 1 to x if x is positive and subtract 1 from x if x is negative but leave x alone if x is 0?
A) if (x > 0) x++;
Else x--;
B) if (x > 0) x++;
Else if (x < 0) x--;
C) if (x > 0) x++;
If (x < 0) x--;
Else x = 0;
D) if (x == 0) x = 0;
Else x++;
X--;
E) x++;
X--;
Correct Answer:
Verified
Q9: Regarding the Software Failure: The operators were
Q10: Assume that count is 0, total is
Q11: Consider the following code that will assign
Q12: Assume that x and y are int
Q13: What is wrong, logically, with the following
Q15: The statement {} is a legal block.
Q16: As in the other members of the
Q17: In order to compare int, float and
Q18: Of the following if statements, which one
Q19: Assume that boolean done = false, int
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents