Turning odd to even....

I am having trouble finding out a way to make odd numbers become even. I am wondering if there is some kind of absolute value button or something like that.

For example i "answer-guess"

ANSWER is a random number. and Guess is an input. So the answer can be 4, and if i enter 12 for guess then the answer would be negative. Is there any way to make it even? And i believe if i just put " (answer-guess) * -1" it would just make a positve number become negative and i wouldnt want that.

And i am trying to make it look somewaht like this

lets say "int diff = answer-guess;" so i want to be able to do this "diff < 10"

and i want it to be a range of 10. so -12 would not work for what i am trying to do.

hope it makes sense!
Last edited on
At first I had no idea what you were talking about.

An odd number is a number that isn't divisible by two. An even number is a number that is.
What you mean is negative number, which is a number lower than zero, and positive, which is a number higher than zero.

To remove the sign from a number, use the function abs() defined in cmath or math.h, depending on whether you're using C++ or C.
OH! yea i see where i confused you. My fault. i should have noticed that yesterday. But thank you for the help, and sorry for the mix up.
Topic archived. No new replies allowed.