Hey, i have made this little guessing game and was wondering how i could clear the screen every time to ask the question if the guess is wrong, though keeping line's 15 and 17 displayer all the time, i've tried but got msessed up programs etc, please help me adjust my code

#include <iostream>
#include <windows.h>

using namespace std;

int main()
{
    unsigned int randomNumber = 0;
    unsigned int guess = 0;
    unsigned int guesses = 0;
    
    srand ( time(NULL) );
    randomNumber = rand() % 1000 + 1;
    
    cout << "Welcome to my simple guessing game!" << endl << endl;
    
    cout << "Guesses : " << guesses << endl << endl;
    
    while(guess != randomNumber)
    {
    
    cout << endl << endl <<"Guess what number i'm thinking of ( 0 - 1000 ) : ";
    cin >> guess;
    
    guesses++;
    
    if (guess > randomNumber)
    cout << endl << "Number too big!";
    
    if (guess < randomNumber)
    cout << endl << "Number too small!";
    
    if (randomNumber == guess)
    {
                     
    cout << endl << "Correct!" << endl << "You guessed in " << guesses;
    cout << "guesses";
    
    system("PAUSE>nul");
    
    }

}
}

have you tried using "clrscr()"....include the header file conio.h..and i tried compiling your code but gives me error time undeclared..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.