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:
Code:
#include <iostream.h>

int mult(int x, int y);

int add(int x, int y);

int sub(int x, int y);

int div(int x, int y);

int main()

{

	int a;

	cout<<"What would you like to do?"<<endl;
	
	cout<<"1.Add"<<endl;
	
	cout<<"2.Subtract"<<endl;
	
	cout<<"3.Multiply"<<endl;
	
	cout<<"4.Divide"<<endl;

	cin>>a;

	if(a==1)

	{

		int x, y;

		cout<<"Please enter two numbers to be added:"<<endl;

		cin>>x>>y;

		cout<<"The sum of your two numbers is "<<add(x, y)<<endl;

		return 0;

	}
Same thing 3 more times, but changed slightly for the different operations...
Code:
}

int add(int x, int y)

{

	return x+y;

}
Again, same thing over and over for different operations.

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