432,245 Members | 884 Online
Need help? Post your question and get tips & solutions from a community of 432,245 IT Pros & Developers. It's quick & easy.

# Guess Program

 P: 41 Hi, I'm starting to learn C++. And I have this assignment and I can't compile it for some reason.. Here is the problem: -> Write a number guessing name program named guess. The program will generate a pseudo random number in the range 0 to 99. The program will then enter an infinite loop and will: 1 - prompt the user to enter a guess between 0 and 99. 2 - read the guess 3 - if the guess and the random number are equal a - the program will print a success message b - exit the program 4 - if the guess is less than the random number, the program will print Low and return to 1 5 - if the guess is greater than the random number, the program will print high and return to 1 6- if the guess is less than 0, the program will terminate Here is my source code. Expand|Select|Wrap|Line Numbers #include  #include  #include  #include  using namespace std;   int main() {     srand ((unsigned)time(0));     int random = rand() %100;     int numbers = 0;       do     {         cout << "Please enter a number between 0 and 99: ";         cin >> numbers;           if ( numbers == random )         {             cout << "Congratulations, you got the right number.";             exit(0);         }              else if ( numbers > random )         {             cout << "High";             continue;         }           else if ( numbers < random )         {             cout << "Low";             continue;         }                                   else if ( numbers < 0 )                                 {                                     exit(0);                                 }     }       return 0;   }   Thank you, Doug Jan 26 '07 #1