0

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");
    
    }

}
}
2
Contributors
1
Reply
2
Views
9 Years
Discussion Span
Last Post by joshmo
0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.