I am fairly new to C++. I was wondering how would one go about checking to see if a value entered by the user was negative or positive. Is this something you might use modulo(%) math for?
A check to see if an integer is negative is the same that you would do logically - is it less than zero?
if (x < 0) {
cout << "It's negative!" << endl;
}
Modulus is a bit different, it's an actual function, and it is the remainder after division, so if you do x % 5, it would be the remaind3er after 5 was divided into x.
I am fairly new to C++. I was wondering how would one go about checking to see if a value entered by the user was negative or positive. Is this something you might use modulo(%) math for?