title: In C Programming, How do I use a loop to ask user if they want to continue?
body: <p>I am a 1st year Computer Science student, currently taking intro to Programming. We are learning the C Programming language and I'm having trouble figuring out how to properly input a loop at the end of my code to ask the user if they want to continue or not.</p>
  
  <p>This simple assignment asks to develop a program that will determine an employee's gross pay (including an "if" statement to determine overtime). As you'll see in my code, I think I've done so correctly. The assignment goes on to state that at the end of my program I should use a loop to ask the user if they want to continue.</p>
  
  <p>In class, we went over For loops, and While loops, but I am a little lost on how to implement this feature correctly. </p>
  
  <p>I initially tried doing something like...</p>
  
  <pre><code>printf("Would you like to continue? (1 = Yes, 2 = No) \n" );
  scanf("%i", _____ ); While (_____ == 'y' || ______ == 'Y') {
  }
  </code></pre>
  
  <p>But not sure what to declare for the input (scanf) or what to put in the while loop. Please help. Its my spring break and no campus tutoring is around. Thanks!</p>
  
  <p>Here's my code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  int main () {
      double totalHours, rate, grossPay, overTime, overTimepay, otHours, grossPaywithOT;
  
      //1. I began by asking user for total hours &amp; getting input
      printf("Enter your total hours worked : \n");
      scanf("%lf", &amp;totalHours);
  
      //Now I'm using a selection statement to determine pay for overtime hours
      if (totalHours &gt; 40) {
          //a. Inform user they have overtime hours
          printf("You worked over 40 hours this period. \n");
  
          //b. Ask how many hours over 40 they worked
          printf("How many hours over 40 did you work? : \n");
          scanf("%lf", &amp;otHours);
  
          //c. Ask the user for hourly rate
          printf("What is your hourly rate? : \n");
          scanf("%lf", &amp;rate);
  
          //d. Overtime Rate Calculation &amp; Gross Pay Calculation
          grossPay = totalHours * rate;
          overTime = 1.5 * rate;
          overTimepay = otHours * overTime;
          grossPaywithOT = overTimepay + grossPay;
  
          //e. Display overtime pay and Gross Pay
          printf("Your overtime pay is %.02lf \n", overTimepay);
          printf("Your total Gross Pay including overtime is %.02lf \n", grossPaywithOT);
      } else {
          //2. Ask the user for hourly rate
          printf("What is your hourly rate? : \n");
  
          //3. User input for hourly rate
          scanf("%lf", &amp;rate);
  
          //4. Gross Pay Calculation
          grossPay = totalHours * rate;
  
          //5. Display grossPay
          printf("Your Gross Pay is %.02lf \n", grossPay);
      }
  }
  </code></pre>