title: Using C, get sum of every other digit not working at all
body: <p>I'm trying to do a simple program that if I inputted - to keep things simple- </p>
  
  <p>Enter</p>
  
  <blockquote>
    <p>5235</p>
  </blockquote>
  
  <p>Print out on screen  </p>
  
  <blockquote>
    <p>length is 4<br>
    sum is 8   </p>
  </blockquote>
  
  <p>Enter</p>
  
  <blockquote>
    <p>54468</p>
  </blockquote>
  
  <p>Print</p>
  
  <blockquote>
    <p>length is 5<br>
    sum is 10  </p>
  </blockquote>
  
  <p>However, only the length seems to be working and I'm not sure why.</p>
  
  <p>I got the total length of the number entered by the user and specified if number is odd then add the even count and vice versa, and yet it doesn't seem to be working.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;cs50.h&gt;
  int main(void)
  {
    long long cc_number;
    long long x;
    long long length;
    int sum, count = 0;
  
    do
    {
      printf("Please Enter Credit Card Number ");
      cc_number= get_long_long();
      x= cc_number;
    }
    while (x&gt;0);
  
    while (x != 0)
    {
      x= x/10;
      length++;
    }
  
    x= cc_number;
  
    while (x != 0)
    {
      x= x/10;
      int digit= (int) (x % 10);
      count++;
      if ((count % 2 == 0) &amp;&amp; (length %2 ==1))
      {
        sum=sum+digit;
      }
      else ((count % 2 == 1) &amp;&amp; (length %2 ==0))
      {
        sum=sum+digit;
      }
    }
  
    printf("the sum is %i", sum);
    printf("the length of the digits is %lli", length);
  }
  </code></pre>