title: Comparing ASCII value of input (C Program)
body: <p>For practice I am trying to create a program that counts the number of each digit, alphabetic character, and "whitespace" character in a line.</p>
  
  <p>My program is printing fine however my counter is not correctly adding each character it reads.  Below is the code for the program (I've only started learning about a week ago so please excuse any glaring issues).</p>
  
  <p>I believe the my main issue rests in the if/else if statements where I compare the int c to a variety of ASCII values.  </p>
  
  <pre><code>/* Print Count of Each Char, Spaces, and Digits */
  
  int main(void) {
      int c, i, CountWhitespace, count, Alpha;
      int CountCharacter[26];
      int CountDigits[10];
  
      CountWhitespace = 0;
      for (i = 0; i &lt; 10; ++i) {
          CountDigits[i] = 0; }
      for (i = 0; i &lt; 26; ++i) {
          CountCharacter[i] = 0; }
  
      while ((c = getchar()) != '\n') {
          if (c &gt;= '0' &amp;&amp; c &lt;= '9') {
              ++CountDigits[c]; }
          else if (c == '\t' || c == ' ') {
              ++CountWhitespace; }
          else if (c &gt;= 'a' || c &lt;= 'z') {
              ++CountCharacter[( c - 'a')]; }
          else if (c &gt;= 'A' &amp;&amp; c &lt;= 'Z') {
              ++CountCharacter[(c - 'A')]; }
      }
      printf("Whitespace Characters: %d\n", CountWhitespace);
      for (i = 0; i &lt; 10; i++) {
          printf("%d appears %d times.\n", i, CountDigits[i]); }
      for (Alpha = 'a', count = 0; count &lt; 26; count++, Alpha++) {
          printf("%c appears %d times.\n", Alpha, CountCharacter[count]); }
  
      return EXIT_SUCCESS;
  }
  </code></pre>
  
  <p>Below is an example of the output:</p>
  
  <p><img src="https://i.stack.imgur.com/na4Rw.png" alt="enter image description here"></p>
  
  <p>The green characters are the input, and as you may be able to tell, none of them are added to their corresponding variables.</p>