Why cant I assign modulous operator into double data type?!
[code] double a;
if ( a % == 0)... ... [\code]
My compiler says: invalid operands to binary %
what is operands?
Printable View
Why cant I assign modulous operator into double data type?!
[code] double a;
if ( a % == 0)... ... [\code]
My compiler says: invalid operands to binary %
what is operands?
The compiler's right. The standard says that the % operator can only be applied to integral types.
You've clearly never heard of a dictionary. Most (if not all) english language dictionaries will define operand as a quantity on which a mathematical operation is performed.
To spell it out, in C, when you write the expression a % b (which gives the remainder left over when dividing a by b) the variables (or values) a and b are the operands.
In your code "a % == 0" is invalid because you have left out the second operand.
If you want to do the equivalent of the modulo operator on floating point types, then look up the function fmod() which is declared in <math.h>.