### Calculator doesn't work

Hi guys, im having an issue by creating a calculator. I'm an absolute beginner since I just started learning Programming some days ago. Can someone tell me what's wrong in this code?

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657`` ``````#include #include using namespace std; int addition(int num1, int num2) { return num1 + num2; } int subtraction(int num1, int num2) { return num1 - num2; } int multiplication(int num1, int num2) { return num1 * num2; } int division(int num1, int num2) { return num1 / num2; } int main() { int number1; int number2; //Addition cout << "You are adding. Enter the first number you would like to add. \n Number 1: "; cin >> number1; cout << " Enter the second number. \n Number 2: "; cin >> number2; cout << " The answer is: " << addition(number1, number2) << endl; //Subtraction cout << "You are subtracting. Enter the first number you would like to subtract. \n Number 1: "; cin >> number1; cout << " Enter the second number. \n Number 2: "; cin >> number2; cout << " The answer is: " << subtraction(number1, number2) << endl; //Multiplication cout << "You are adding. Enter the first number you would like to multiply. \n Number 1: "; cin >> number1; cout << " Enter the second number. \n Number 2: "; cin >> number2; cout << " The answer is: " << multiplication(number1, number2) << endl; //Division cout << "You are dividing. Enter the first number you would like to divide. \n Number 1: "; cin >> number1; cout << " Enter the second number. \n Number 2: "; cin >> number2; cout << " The answer is: " << division(number1, number2) << endl; } When I run it, it prints : 10Press``````
any key to continue...
Last edited on
That is quite odd. Have you compiled it? Maybe you are running your previous program. And when posting code, please select it and press the <> button (then it gets formatted).
I fixed the topic.. but im always compiling before running, so .. i'm pretty sure that im not running the previous one.

Well, i just tried in Bloodshed Dev C++ and it worked, but it didnt work on Visual C++ 2010 Express.
Last edited on
 ``1234`` ``````int subtraction(int num1, int 2) { return num1 - num2; }``````

should be:

 ``1234`` ``````int subtraction(int num1, int num2) { return num1 - num2; }``````

what do you mean it prints 10?
yes, I noticed that when compiling in Bloodshed Dev C++. When I tried in Visual C++ Express, it didn't show any error, and the result was different from Bloodshed Dev C++.

Bloodshed Dev C++ worked properly
Visual C++ 2010 Express did not work properly.. i don't know why.

I mean that everything that shows in the console is :

"10Press any key to continue"

Last edited on
Topic archived. No new replies allowed.