You need both ignore() (to eat the newline the user entered) and get() (to keep your console window from closing).
Code:#include <iostream> using namespace std; int main ( int argc , char** argv ) { srand(time(0)); int random_number = rand() % 10 + 1 ; cout << "Guess a number between 1 and 10\n"; int guess; cin >> guess; if (guess==random_number) { cout << "Correct!"; } else if (guess!=random_number) { cout << "Wrong!"; } cin.ignore(80,'\n'); cin.get(); }