title: C Looping a switch using Y/N options. Choosing N doesn't close the program
body: <p>I've only started coding C. (freshman here, no experience, only basic html)
  For some reason, whenever I choose the option 'N', it just creates a new line. </p>
  
  <p>At my second <code>scanf</code> whenever I change my <code>'%s'</code>, the result changes. 
  When I use, <code>"%d"</code>,after entering a number, it continuously enter "<code>Choose a number between 1-4</code>". If I use <code>"%c"</code>,after entering a number, it will skip directly to the loop. Help?</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  int main()
  {
      int n, ok = 0;
      char input;
      while (ok == 0)
      {
            printf("Choose a number between 1-4\n");
            scanf("%d", &amp;n);
            switch (n)
            {
                   case 1:
                        printf("You've chosen number 1");
                        break;
                   case 2:
                        printf("You've chosen number 2");
                        break;
                   case 3:
                        printf("You've chosen number 3");
                        break;
                   case 4:
                        printf("You've chosen number 4");
                        break;
                   default:
                           printf("You have chosen an invalid number");
            }
            printf("\nInput again? (Y/N)\n");
            scanf("%s", &amp;input);
            if (input=='n'||input=='N')
            {ok++;}
            else if (input=='Y'||input=='y')
            {printf("\n");}
  
  
      }
  
   getchar();
   getchar();   
  }
  </code></pre>