title: Boolean function in program returns that an entered range is invalid no matter what
body: <p>I am working on a program that determines if there are numbers with repeating digits within a range. The program itself works fine - but one component of it is determining whether or not the user entered range is valid. It is required that I make a boolean function for this called range_is_valid. The two inputs are a and b, if b
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;vector&gt;
  #include &lt;stdbool.h&gt;
  using namespace std;
  
  
  //function for finding repeating digits
  bool has_repeating_digits(int number){
      bool hasDigit[10] = {false, false, false, false, false, false, false, false, false, false};
      int count = 0;
      while (number &gt; 0) {
          int digit = number % 10;
          if (hasDigit[digit]){
              return true; // We already have this digit0
          }
          hasDigit[digit] = true; // Flag the digit we just found
          number /= 10; // Divide by 10, to move onto the next digit
      }
      return false; // If we get here, there is no repeat digit
  }  
  
  //function for counting valid numbers
  int count_valid_nums(int a, int b, int count){
      int validnums = ((b - a) + 1) - count; //the total range minus the count of invalid nums leaves just valid nums
      return validnums; 
  }
  
  //function for determining if inputted range is valid
  bool range_is_valid(int a, int b){
      if ((a &gt; b) || (a &lt; 0) || (b &lt; 0) || (a &gt; 10000) || (b &gt; 10000)) {
          return false; //if any of those are true then invalid range
      }
  }
  
  int main(){
      //variables
      int a, b, i, count= 0; // a &amp; b inputs, i for iterating
  
      //entering number range
      cout &lt;&lt; "Enter numbers 0 &lt; a &lt;= b &lt;= 10000: " &lt;&lt; endl;
      cin &gt;&gt; a;
      cin &gt;&gt; b;
  
      //Check if the range is valid
      range_is_valid(a,b);
      if (range_is_valid(a, b) == false){
          cout &lt;&lt; "The range is invalid" &lt;&lt; endl;
      }
  
      //making a vector to contain numbers between a and b
      vector&lt;int&gt; listofnums((b-a)+1); 
      int initialvalue = a;
      while (i &lt;= (b-a)) {  
          listofnums[i] = initialvalue;                                 
  
  
          //call the has repeating digits function
          has_repeating_digits(listofnums[i]);
          if (has_repeating_digits(listofnums[i])){ //counting how many numbers in vector have repeat digits
              count++;
          }   
          initialvalue++; 
          i++;
  
      }
  
      //call the count valid numbers function
      cout &lt;&lt; "There are " &lt;&lt; count_valid_nums (a, b, count) &lt;&lt; " valid numbers between " &lt;&lt; a &lt;&lt; " and " &lt;&lt; b &lt;&lt; endl;
  
      return 0;
  }
  </code></pre>