Why Isn't My Code Working.
I'm trying to make a basic calculator using C++ with 6 operations but it isn't working: When I use double as a data type to store my numbers, I get an error. I also removed the exponent operator because of many other errors. Please help. Here is my code: int main() { //Declaring the variables I'm going to use in the program. double num1, num2; //I used doubles for more efficiency in the program. string op; //Storing the operator in the code cout << "Enter the first number:" << endl; cin >> num1; cout << "Enter the operator" << endl; cin >> op; cout << "Enter the second number:" << endl; cin >> num2; double res; //storing result of operation if (op == "+") { res = num1 + num2; cout << res << endl; } else if (op == "-") { res = num1 - num2; cout << res << endl; } else if (op == "/") { res = num1 / num2; cout << res << endl; } else if (op == "%") { res = num1 % num2; cout << res << endl; } return 0; } I get this error: ./Playground/file0.cpp: In function 'int main()': ./Playground/file0.cpp:38:20: error: invalid operands of types 'double' and 'double' to binary 'operator%' 38 | res = num1 % num2; | ~~~~ ^ ~~~~ | | | | double double