title: Why does my switch statement print a case and default?
body: <pre><code>#include &lt;stdio.h&gt;
  
  int main(void)
  {
      char ch;
      int end=0;
      printf("\nPick a letter a through f. (f ends the program)");
      do
      {
          scanf("%c", &amp;ch);
  
          switch (ch) {
      case 'a':
          printf("a. another: ");
          break;
      case 'b':
          printf("b. another: ");
          break;
      case 'c':
          printf("c: another ");
          break;
      case 'd':
          printf("d. another: ");
          break;
      case 'e':
          printf("e. another:  ");
          break;
      case 'f':
          printf("f. Goodbye. ");
          end=1;
          break;
      default:
          printf("That wasn't a through f. ");
          break;
          }
      } while (end == 0);
      return 0;
  }
  </code></pre>
  
  <p>So if you enter a then it will say:</p>
  
  <pre><code>a. another: That wasn't a through f.
  </code></pre>
  
  <p>If you enter say g then it will say:</p>
  
  <pre><code>That wasn't a through f. That wasn't a through f. 
  </code></pre>
  
  <p>If you enter f then it will do as expected</p>
  
  <pre><code>f. Goodbye.
  </code></pre>
  
  <p>and the program terminates.</p>
  
  <p>Any tips on how to fix this? I've tried looking it up for a while and I get answers not in C or they say you're forgetting a break; statement. I'm new to C, as well so maybe it's something obvious I'm not noticing, I also thought it might be due to something with the do while loop? Thanks for your time</p>