My Code Is Closing
Mar 27, 2014 at 1:19pm UTC
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
#include<iostream>
using namespace std;
int main(void )
{
double dnumber1 = 0.0;
double dnumber2 = 0.0;
double dnumber3 = 0.0;
double daverage = 0.0;
cout << "please enter enter 3 number: " << endl;
cin >> dnumber1;
cin >> dnumber2;
cin >> dnumber3;
daverage = (dnumber1 + dnumber2 + dnumber3) / 3;
cout << "the average of the numbers are: " << daverage << endl << endl;
return 0;
system("PAUSE" );
}
This code is closing it self after:
1 2 3 4
cout << "please enter enter 3 number: " << endl;
cin >> dnumber1;
cin >> dnumber2;
cin >> dnumber3;
Why? Please, help.
Mar 27, 2014 at 1:23pm UTC
I recommend taking a look at here:
http://www.cplusplus.com/forum/beginner/1988/
the issue isn't your code, mind you. Programs tend to continue to run so quickly that by the time line 18 is executed and visible, the program already closes from completion. In that thread are various methods to prevent this. Avoid any that use system.
Last edited on Mar 27, 2014 at 1:23pm UTC
Topic archived. No new replies allowed.