title: yes or no to exit a switch statement
body: <p>Is it possible to create yes or no function to be called to exit a <code>switch</code> statement. if (y)es is hit it would exit. If (n)o is hit it would loop back to the switch's options. if so how would this be done. This is what I have so far.</p>
  
  <p>I hope this helps to clarify what I am trying to do</p>
  
  <pre><code>int yes_no(void) {
  
      scanf("%d", &amp;option);
  
      while (option == 'y' || option == 'Y' || option == 'n' || option == 'N') {
          if (option == 'y' || option == 'Y') {
              return 1;
          } else
          if (option == 'n' || option == 'N') {
              return 0;
          } else {
              printf("Only (Y)es or (N)o are acceptable");
          }
      }
  }
  
  int main(void) {
      int select;
  
      do {
          printf("0 exit");
          printf("1 hello");
  
          scanf("%d", &amp;select);
  
          switch (select) {
            case 0:
              printf("Exit the program? (Y)es or (N)o :");
              yes_no(); // if (n)o is hit it will loop back to the menu
              break;
            case 1:
              printf("hello how r u doing");
              break;
            default:
              printf("not accepted number");
          }
      } while (select != 0);
  }
  </code></pre>