n is a float, so the suggested method above will not work because you cann't do a modulo operation on a floating point number.
Is there a reason you are using a float?
EDIT: There are other problems. Comparing floats to exact numbers is questionable at best due to imprecision. If you use fmod() you wouldn't be able to compare it to 0.0 reliably. so fmod(n,2)==0, where n is an even number, might return false when it should be true. Instead you'd have to compare it to a small epsilon range which doesn't really support what you were trying to determine in the first place.








