title: Determine if a number contains a digit for class assignment
body: <p>Write a function named <code>containsDigit</code> that determines if a number contains a particular digit.</p>
  
  <p>The header should look like:</p>
  
  <pre><code>bool containsDigit(int number, int digit);
  </code></pre>
  
  <p>If number contains digit, then the function should return <code>true</code>. Otherwise, the function should return <code>false</code>.</p>
  
  <pre><code>Input: 
  147 9
  
  Output: 
  false
  </code></pre>
  
  <p>I don't know why I always get false when I write like this:</p>
  
  <pre><code>bool containsDigit(int number, int digit);
  
  int main() {
    double con;
    int number, digit;
    cout &lt;&lt; "Input a number and a digit:\n";
    cin &gt;&gt; number &gt;&gt; digit;
    con = containsDigit(number, digit);
    cout &lt;&lt; con;
    return 0;
  }
  
  bool containsDigit(int number, int digit) {
    int a(0), b;
    b = number;
    while (number &gt; 0) {
      a = a + 1;
      number = number / 10;
    }
    cout &lt;&lt; a;
    while (a &gt; 1) {
      a = a - 1;
  
      if (b / pow(10, a) == digit) {
        cout &lt;&lt; "true\n";
        break;
      } else {
        if (a == 1)
          cout &lt;&lt; "false\n";
        else
          cout &lt;&lt; "";
      }
      b = b % pow(10, a);
    }
  }
  </code></pre>