In C++, the modulus operator, %, takes any numeric operands. (True or False)
Yes.. it's true that modules operator take integers.
For example : x% y
1. If y is divided by x, then result is 0.
2. If y is not divisible bt x, then reminder will be in range of (1, x-1)
3. If x is 0 then it leads to division by zero
Note that
1. % operator is not applied to floating or double numbers which leads to compiler error.
2. For negative integers, it's based on machine independent.. some compiler gives result as 1 for negative and some gives as -1 for negative
Get Answers For Free
Most questions answered within 1 hours.