Can you write down the sets of statements below will add 1 to x if x - ProProfs Discuss
Advertisement

Can you write down 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?

Can you write down 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?<br/>

Change Image    Delete

Asked by Justinsmith, Last updated: Dec 02, 2024

+ Answer
Request
Question menu
Vote up Vote down

2 Answers

John Adney

John Adney

John Adney
John Adney

Answered Dec 05, 2017

If (x > 0) x++;else if (x < 0) x--;

upvote downvote
Reply 

John Smith

John Smith

John Smith
John Smith

Answered Oct 31, 2016

If (x == 0) x = 0; else x++; x--;
upvote downvote
Reply 

Advertisement
Advertisement
Search for Google images Google Image Icon
Select a recommended image
Upload from your computer Loader
Image Preview
Search for Google images Google Image Icon
Select a recommended image
Upload from your computer Loader
Image Preview
Search for Google images Google Image Icon
Select a recommended image
Upload from your computer Loader

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