title: Why am I getting the error "Break statement not within loop or or switch."?
body: <p>This simple program asks the use's age and based on that displays a message.At the end if it,the user is asked if he would like to repeat the whole thing again.But I am getting the error </p>
  
  <blockquote>
    <p>Break statement not within loop or switch</p>
  </blockquote>
  
  <p>when I compile it. What does that mean and how do I correct it?</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  
  static int prompt_continue (const char *prompt)
     {
         printf("%s", prompt);
         char answer[5];
         if (scanf("%1s", answer) != 1)
       return 0;
  
         if (answer[0] == 'y' || answer[0] == 'Y')
  
  {
      int c;
      while ((c = getchar()) != EOF &amp;&amp; c != '\n')
      ;
      return 1;
  }
  return 0;
     }
  
     int main(void)
  {
  /*Creates a simple program using if else example. */
  
  
  
  int age;
  
     while (printf("Welcome, this program is designed for if else statements.\n"));
     printf("Please enter your age.\n");
  
     scanf (" %d", &amp;age); /*Enters age.*/
     if (age &lt; 18){
     printf("You are young!\n");
  }
  
  else if (age &gt; 18){
      printf("Ah you're old!\n");
    }
  
    {
      printf(" Woot.\n");
      if (prompt_continue("Do you want to try again? Y/N") == 0)
      break;
    }
  
  
  
     return 0;
  }
  </code></pre>
  
  <p>Just trying to work through this, need a little help.  Did I use the while loop wrong? Any thoughts would be helpful. Thanks!</p>