Which of the sets of statements below will add 1 to x if x is - ProProfs Discuss
Topics
Products
Follow Us:

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 = 0;else x++;x--;
D. X++;x--;

This question is part of Computer Programming II Exam (Multiple Choice)
Asked by Justinsmith, Last updated: Apr 06, 2020

+ Answer
Request

1 Answer

justinsmith

Justinsmith

Answered Mar 14, 2018

If (x == 0) x = 0; else x++; x--;
 

Search for Google images
Select a recommended image
Upload from your computer
Search for Google images
Select a recommended image
Upload from your computer
Search for Google images
Select a recommended image
Upload from your computer

Email Sent
We have sent an email to your address "" with instructions to reset your password.