title: how to check if a number is of 4 digits in c++?
body: <p>How to check if a number is of 4 digits in c++?
  I have tried this code:</p>
  
  <pre><code>bool check4(int number)
  {
       if ((number % 10) &amp;&amp; !(number / 10000) &amp;&amp; (number / 1000) &amp;&amp; (number / 100) &amp;&amp; (number / 10))
           return true;
       else
           return false;
  }
  </code></pre>
  
  <p>It works only for numbers that not contain 0, like 1234 , 5678 etc.</p>
  
  <p>Can someone show me how to fix it?</p>
  
  <p>Thanks! </p>