Using cin in a simple number game

I am very new to C++ and working through an exercise writing programs using do, if, while statements.
The problem given by the instructor was simple: Write a number guessing program. 1 user inputs a number and than another inputs a number, programs says the "secret number" is higher or lower until the number is guessed.

The problem is when the "secret number" is inputed it stays on the output negating the "fun" in playing the game.

Essentially once a value is inputed can it be hidden?

Here is my code so far:
// The Number Game //

#include <iostream>
using namespace std;

int main ()
{
int secretnum, guess;

cout << "The World Famous Number Game!" << endl;
cout << "\nPlayer 1 please look away from the screen"
<< "\nPlayer 2 please enter any number: " << endl;
cin >> secretnum;

cout << "Player 2 LEAVE THE ROOM!!!" << endl;

do
{
cout << "Player 1 enter a guess at the number: ";
cin >> guess;

if (guess < secretnum)
cout << "The secret number is higher" << endl;
else if (guess > secretnum)
cout << "The secret number is lower" << endl;
else if (guess == secretnum)
cout << "YOU WIN!!! The secret number was " << secretnum << endl;
}
while (guess != secretnum);

return 0;
}
See http://cplusplus.com/articles/4z18T05o/
Though the simplest thing would be to generate that number randomly.
Topic archived. No new replies allowed.