I wrote a calculator program earlier, and I got everything to work fine in the compiler. However, I have run into a problem when running it outside of the compiler. After it displays the sum/difference/product/quotient of the given numbers, it closes the window before I can see the solution. I've tried putting system("pause") before return 0; in each block of code for the operations, but it does nothing but generate errors. Here's all the necessary code:
Same thing 3 more times, but changed slightly for the different operations...
int mult(int x, int y);
int add(int x, int y);
int sub(int x, int y);
int div(int x, int y);
cout<<"What would you like to do?"<<endl;
int x, y;
cout<<"Please enter two numbers to be added:"<<endl;
cout<<"The sum of your two numbers is "<<add(x, y)<<endl;
Again, same thing over and over for different operations.
int add(int x, int y)
If anybody can tell me what I can put in there to get it to stay open long enough for me to read the output, I will be very thankful... Also, can somebody tell me what I can use instead of int so I can use decimals instead of being restricted to integers? Thank you in advance