I just started c++ yesterday and i'm trying to make a calculator.
I'm using switch and cases to make +, - , *, and / and to get the answers but when i get the answer all i can make it do is close the program. How can i make the program reset whenever i need it to?
Thanks ~GameGenie
If it helps this is the code for the prgram....
Code:#include <iostream> using namespace std; int main() { //Declaring variables. int calc; int add1; int add2; int sub1; int sub2; int mul1; int mul2; int div1; int div2; //Print the selections cout<< "Selection 1: +\n"; cout<< "Selection 2: -\n"; cout<< "Selection 3: *\n"; cout<< "Selection 4: /\n"; //Get the selection. cin>> calc; //Make the selections. switch ( calc ) { case 1: cout<< "You have choosen to add...\n"; cout<< "Enter the first number you wish to add:\n"; cin>> add1; cout<< "Enter the second number you wish to add:\n"; cin>> add2; cout<< "The answer is: " << ( add1 + add2 ); break; case 2: cout<< "You have choosen to subtract...\n"; cout<< "Enter the first number you wish to subtract:\n"; cin>> sub1; cout<< "Enter the second number you wish you subtract:\n"; cin>> sub2; cout<< "The answer is: " << ( sub1 - sub2 ); break; case 3: cout<< "You have choosen to multiply...\n"; cout<< "Enter the first number you wish to multiply:\n"; cin>> mul1; cout<< "Enter the second number you wish to multiply:\n"; cin>> mul2; cout<< "The answer is: " << ( mul1 * mul2 ); break; case 4: cout<< "You have choosen to divide...\n"; cout<< "Enter the first number you wish to divide:\n"; cin>> div1; cout<< "Enter the second number you wish to divide:\n"; cin>> div2; cout<< "The answer is: " << ( div1 / div2 ); break; default: cout<< "Sorry, thats not one of the choices. \n"; break; } cin.get(); cin.ignore(); }