Modulo issue

if (arrayLength % 2 == 0) //ERROR: invalid operands of types ‘double’ and ‘int’ to binary ‘operator%’

The type of "arrayLength" is a double and I guess you can't find the modulo of a double and int. I tried changing the 2 to 2.00 as well as creating a double with the value of 2 so that both values are doubles and neither worked. arrayLength must be a double in order for the result to be accurate.

Is there any way to get around this?
why would the length of an array be anything other than an integer? In other words, wouldn't it be better to declare arrayLength as an int?
Last edited on
Makes sense... Good thing I posted this in the beginner category lol. Thanks
Topic archived. No new replies allowed.