Problem with output not staying up on the screen

Here is my code:

#include <iostream>
#include <iomanip>

using namespace std;
int main()
{
//declare variables

double year1 = 0.0;
double year2 = 0.0;
double year3 = 0.0;
double salary = 0.0;
double raise = 0.0;
double totalSalary = 0.0;
const double rate = .05;

//Enter Salary
cout << "Enter Annual Salary: $ " ;
cin >> salary;

// Calculation

year1 = salary *(1.+ rate);
year2 = year1 * (1.+rate);
year3 = year2 * (1.+rate);
totalSalary = year1 + year2 + year3;

cout << fixed << setprecision(2);

cout << "After Year 1: $ " << year1 << endl;
cout << "After Year 2: $ " << year2 << endl;
cout << "After Year 3: $ " << year3 << endl;
cout << "Total salary for the three years:$ " << totalSalary << endl;

//system("pause");
return 0;
} //end of main function

My problem it is not staying up on the screen with the option to 'Press any key to continue.'

Would someone please help me with this. I am a beginner.
You commented out the call to system()...
//system("pause");
Should be just
system("pause");
(or an equivalent to that)
Here's a nice long thread about this:
http://cplusplus.com/forum/beginner/1988/
lets do one thing!

Initialise a variable like

int waiter;
now after completing all your programming and other codes, place the following line just before the return 0; statement.

cin>>waiter;

With this statement placed just before the 'return 0' statement, will make the program to wait for another input from the user and thus wait for an "input" and hence the output will stay on the screen until an input is given.

Hope this helps!
Topic archived. No new replies allowed.