0
Is there a shorter way of dong this
I am not supposed to get a negative number in the end is there a way to make it so if I get a negative number it changes it to positive? Instead of writing if (agemonth == -1) { cout << 1} for every number?
3 Answers
+ 3
if(agemonth < 0)
cout << -agemonth;
+ 1
Just use unsigned int.
0
Jay Matthews I am not sure but somewhere I read that mod with negative is implementation defined and hence it behaves differently for different compiler... No offense but want to make this understanding clear for me..