title: C++ 1-100 guessing game where the computer is the one guessing
body: <p>I'm working through some questions in the text Principles and Practice using C++ and the specific question I'm having an issue with is the following. A user must think of a number between 1 and 100 then the computer will figure out what the question is by a series of guesses.</p>
  
  <p>The current code works except for the number 1 (due to the rounding down of integers when dividing by 2). I can't seem to think of a way to fix this.</p>
  
  <p>Here is the current source code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  const int MAX_VALUE = 100;
  const int MIN_VALUE = 1;
  
  int guess;
  int high = MAX_VALUE;
  int low = MIN_VALUE;
  
  char choice;
  
  int main(){
  
  
  cout&lt;&lt;"Think about a number between "&lt;&lt;MIN_VALUE&lt;&lt;" and "&lt;&lt;MAX_VALUE&lt;&lt;". \n\n";
  guess = ( high-low ) / 2;
  
  while((high-low)!=1){
      cout&lt;&lt;"Is your number less than or equal to "&lt;&lt;guess&lt;&lt;"? \nEnter y or n. \n\n";
      cin&gt;&gt;choice;
  
      if(choice=='y' || choice=='Y') {
          high = guess;
          guess -= ( high - low ) / 2;
      }
      else if(choice=='n' || choice=='N') {
          low = guess;
          guess += (high - low ) /2;
      }
      else cout&lt;&lt;"Incorrect choice."&lt;&lt;endl;
  
  
  }
  cout&lt;&lt;"Your number is: "&lt;&lt;high&lt;&lt;".\n";
  
  system("pause");
  return 0;
  }
  </code></pre>