I am trying to make a calculator, but it is being weird for no apparent reason.
Whatever I do, the answers are nothing like they are supposed to be. If I enter this into the "seems like this program requires input" box, num1= 10; num2 = 10; It says this: Added: -2 Subtracted: 2 Divided: 0 Added: 0 Why is it doing this? And if I just enter 10, then it does this: Multiplied: -20 Divided: -5 Added: 8 Subtracted: 12 Here is the code: /* This is my C++ calculator Here are the abilites and how to use them: Addition: Type them in like this: X+Y So if I wanted to add 10 and 6, I would type it in like this: 10+6 Then the program would output 16 For subtraction, replace the + with a -. For multiplication, enter the same, but instead of a +, use a *. For 10 times 6, I would enter this: 10 6 That would output 60. For division, replace the * with a /. Now for some slightly more complicated stuff: Modulus: AKA the % sign Type in your numbers like so: X % Y, no need for spaces, but they are OK. Square root: Type in this first: sqrt() Then, inside the (), put in your number. sqrt(25) Outputs 5 You can also put in an entire exression if you want to. sqrt(5*5*5*5) Outputs 25 Then trigonometry: cos(numbers) sin(numbers) tan(numbers) */ #include <iostream> #include <cmath> using namespace std; int main() { int num1; int num2; int mul; int divi; int add; int sub; cin >> num1 >> num2; mul=num1*num2; divi=num1/num2; add=num1+num2; sub=num1-num2; cout << "Multiplied: \n" << mul << endl; cout << "Divided: \n" << divi << endl; cout << "Added: \n" << add << endl; cout << "Subtracted: \n" << sub << endl; return 0; } Link to code: https://code.sololearn.com/c8Ly51qF2rz3/#cpp