title: Classifying digits of an integer value
body: <p>I spent a day on this code for count even and zero and odd numbers </p>
  
  <p>From long datatype I used a function to send data. Here is the code </p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  void digitCount(long long int &amp;num);
  
  int main ()
  {
      long long int num;
  
      cout &lt;&lt;"Enter any No. " &lt;&lt;endl;
      cin &gt;&gt;num;
      cout &lt;&lt;endl;
  
      digitCount(num);
  
      return 0;
  }
  
  
  void digitCount(long long  int &amp;num)
  {
      int e = 0, z = 0, o = 0, x = 0;
      for (int i = 0; i &lt;= num; i++)
      {
          x= num % 10;    
          if(x == 0)
          {
              ++z;
              num = num / 10;
          }
          else if(x%2==1)
          {
              ++o;
              num = num / 10;
          }
          else
          {
              ++e;
              num = num / 10;
          }  
      }
  
      cout &lt;&lt; "No of zeros Digits = " &lt;&lt; z&lt;&lt; endl;
      cout &lt;&lt; "No of odd Digits = " &lt;&lt; o &lt;&lt; endl;
      cout &lt;&lt; "No of Even Digits = " &lt;&lt; e &lt;&lt; endl;
  }
  </code></pre>
  
  <p>the problem is when I count odd numbers there is a number missed </p>
  
  <p>for example when i input : 12345 </p>
  
  <p>the result is </p>
  
  <pre><code>no of even : 2 
  no of odd :  2 (should be 3)
  no of zero : 0 
  </code></pre>
  
  <p>and here the question : </p>
  
  <p>Write a function that takes as parameter an integer (as a long value) and returns the number of odd, even, and zero digits. Also write a program to test your function. Use pass by reference method.</p>