-4

I have written the following program, and it doesn't print properly. The console appears to simply close after I input the rate and hours.

#include "stdafx.h"
#include <iostream>
using namespace std;
int main()
{
    double hours, rate, pay;
    // Get the number of hours worked.
    cout << "How many hours did you work? ";
    cin >> hours;
    // Get the hourly pay rate.
    cout << "How much do you get paid per hour? ";
    cin >> rate;
    // Calculate the pay.
    pay = hours * rate;
    // Display the pay.
    cout << "You have earned $" << pay << endl;
    return 0;
}
Tas
  • 7,023
  • 3
  • 36
  • 51
panzer67
  • 3
  • 1
  • 1
  • 1
  • what do you mean by 'not debugging'? – Fureeish Aug 27 '17 at 22:56
  • This program runs, compiles and can be stepped into just fine. I don't understand what your problem is. – Michaël Roy Aug 27 '17 at 23:01
  • for me it just exits after u put in hours and time i dont understand i think its a configuration problem with visual studio? – panzer67 Aug 27 '17 at 23:05
  • @panzer67 -- *it just exits after u put in hours and time* -- What did you expect it to do? Nothing in your program says "sit here and wait forever". – PaulMcKenzie Aug 27 '17 at 23:07
  • Hi @panzer67, I basically just [rewrote your question](https://stackoverflow.com/revisions/45910044/2) to be what I suspect you are trying to ask, as in its previous format it was very unclear. If this is not what you're trying to ask, you may roll the edit back and [edit] the question yourself to make it clearer. – Tas Aug 27 '17 at 23:44

1 Answers1

0

The program prints the result and exits. That's normal behaviour. You can add system("pause"); before the return statement to delay the closing of the console.

Michaël Roy
  • 6,338
  • 1
  • 15
  • 19