I learned how to create a calculator that adds numbers, but that is all it does. I want to create a calculator that can add, subtract, multiply, and divide, but I just don't know how to do that. Is there a code for that, or is it impossible?
int number1, number2;
cout << "Choose your operation. \n ";
cout <<"1 = Addition \n" ;
cout <<"2 = Subtraction \n" ;
cout <<"3 = Multiplication \n" ;
cout <<"4 = Division \n ";
cout <<"0 = EXIT \n \n";
cout << "Choice : ";
cin >> choice;
cout << "You are Adding. Enter a number you would like to add. \n Number 1: ";
cin >> number1;
cout << " Enter a second number. \n Number 2: ";
cin >> number2;
cout << " The answer is: "<< number1 + number2 << endl;
cin.get() //This is used to pause the program
case 2: //subtraction... ect.
case 3: //multiply...
case 4: //divide...
This is just an example though. Im sure that there are many ways to clean it up, and if i missed anything i apologize. Case 2, 3 and 4 are basically the same as 1, just using different operators. You could also use a loop to keep the program going until you quit. Hope this helps.