title: C++ program that sums the numbers between two integers
body: <p>Here is my code, it works when x &lt; y. But not when x > y. How can I fix this? I know the problem is within the while loop and I have tried many different things but cannot solve the issue.</p>
  
  <pre><code>int main()
  {
      int x,y;
  
      int total = 0;
      cout&lt;&lt;"Please give me an integer: ";
      cin &gt;&gt; x;
  
      cout&lt;&lt;"Please give me another integer: ";
      cin &gt;&gt; y;
  
      int counter = x;
      while(counter &lt;= y ){
  
          total += counter;
          ++counter;    
      }
  
      cout &lt;&lt; "The total of the numbers " &lt;&lt; total&lt;&lt;endl;      
  }
  </code></pre>