+ 1
% invalid operand
The modulus operator (%) is informally known as the remainder operator because it returns the remainder after an integer division. But when I write the code #include <iostream> using namespace std; int main() { int x = 100.25 + 60.25-40.25*10.25/5.25 % 11.25; cout << x; return 0; } when we click run button; output as below: ..\Playground\: In function 'int main()': ..\Playground\:6:46: error: invalid operands of types 'double' and 'double' to binary 'operator%' int x = 100.25 + 60.25-40.25*10.25/5.25 % 11.25;
1 Respuesta
+ 6
You just said it there:
"For integer division."
You were operating with floating-point values.