Hi guys I am new to the C++ programming but I am learning it, some of it anyway. Problem when I excute my program it will automatically return back to the coding. I don't get to see my results. WHY
I thank you in advance
JB
Problem
Moderator: Moderators
it's been a long time but ...
I think this will do it for you. You'll need to see which include has PAUSE in it.
int main()
{
... put this right after your results are displayed
system("PAUSE");
... press a key to continue (back to your code)
}
int main()
{
... put this right after your results are displayed
system("PAUSE");
... press a key to continue (back to your code)
}
-
- Forum Moderator
- Posts: 1420
- Joined: 2003-04-22 14:37
Here chech this out
here is my code and were I put the system Pause
//T3AppE02.cpp - calculates and displays the new weekly pay
#include <iostream>
using namespace std;
int main()
{
//declare variables
float currentPay = 0.0;
float rate = 0.0;
float raise = 0.0;
float newPay = 0.0;
//enter input items
cout << "Enter current weekly pay: ";
cin >> currentPay;
cout << "Enter raise rate: ";
cin >> rate;
//calculate raise and new pay
raise = currentPay * rate;
newPay = raise + currentPay;
//display output item
cout << "New pay: " << newPay << endl;
sysrem ("Pause");
return 0;
} //end of main function
//T3AppE02.cpp - calculates and displays the new weekly pay
#include <iostream>
using namespace std;
int main()
{
//declare variables
float currentPay = 0.0;
float rate = 0.0;
float raise = 0.0;
float newPay = 0.0;
//enter input items
cout << "Enter current weekly pay: ";
cin >> currentPay;
cout << "Enter raise rate: ";
cin >> rate;
//calculate raise and new pay
raise = currentPay * rate;
newPay = raise + currentPay;
//display output item
cout << "New pay: " << newPay << endl;
sysrem ("Pause");
return 0;
} //end of main function
-
- The Creator Himself
- Posts: 296
- Joined: 2003-01-02 17:15
That's not a very good way because it's system dependant. Better not to move outside C++, and do something like
Then you don't need to include cstdlib either. system is a legacy function from the old times of C...
Code: Select all
cout << "Press any key";
cin.get();