Output not staying up to continue

Ok, when I compile this program after putting in current salary it is coming up for a slit second and then goes away. I can see it is giving me the correct output but it is not asking me to hit any key to continue.

[code]#include <iostream>
#include <iomanip>

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

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

for (int year = 1; year < 4; year += 1)
{
raise = salary * rate;
salary += raise;
cout << "Raise amount for year " << year << "is $" << raise << endl;
totalSalary += salary;
// end for statement
cout << "Total Salary is $: " << totalSalary << endl;
return 0;
}

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

[/code
return 0;
This ends the function it is in.

You have it inside your for loop, in the function main, so the very first time the for loop runs, your main function ends.
Thank you. That worked.
Topic archived. No new replies allowed.