-
The code doesn't stay!
Hi, ive just signed up, ive wrote my first C++ program, but it terminates as soon as i enter an interger, plz help me!
Code:
#include <iostream>
using namespace std;
int main ()
{
int x;
cout << "Please enter an interger to continue...";
cin >> x;
if (x < 0)
cout << "You entered a negative number! Program terminated!";
else if (x > 0)
cout << "Thank you for participating in this program!" << endl;
return 0;
}
-
-
thank you for trying to help, but i dnt understand
-
Maybe if you read the link provided again?...
-
Yes, thank you, but i want to run it from my compiler/editor
any ideas?
-
-
it still doesnt work
this is the code ive got now...
Code:
#include <iostream>
using namespace std;
int main ()
{
int x;
cout << "Please enter an interger to continue...";
cin >> x;
if (x < 0)
cout << "You entered a negative number! Program terminated!";
else if (x > 0)
cout << "Thank you for participating in this program!" << endl;
cout << "Press enter to continue...";
cin.get();
return(0);
}
-
Place cin.ignore() before the cin.get().
(it's about time someone changes that FAQ ;) )
-