title: How to break out of a loop in C
body: <p>I'm writing a bisection method algorithm to find the roots of polynomials. The second part of my code where it says if variable <code>FP</code> is equal to zero or absolute value of <code>b-a</code> it just breaks the if statement I guess.</p>
  
  <p>I want the program to stop the for loop (iteration) entirely and return p. And at the end I want to print the number of iteration it took to get the solution but apparently using my printf statement it shows that the program keeps executing even thought the root (zero) is obtained.</p>
  
  <p>Any ideas on how to stop the whole mechanism and return both the value of p which is zero and the exact number of iteration it took? Thanks</p>
  
  <pre><code>double computeroots(double a, double b, double epsilon, int MaxIter)
  {
      double FA = pow(a,4) -4*a +  1;
      double FB = pow(b,4) - 4*b + 1;
      double FP;
      double p;
      int i;
  
      for(i=0;i&lt;MaxIter;i++) {
          if(FA * FB &lt; 0) {
              p = a + (b-a)/2;
              FP = pow(p,4) - 4*p +1;
              if(FP == 0 || abs(b-a) &lt; epsilon) {
                  return p;
                  break;
              } else if (FA * FP &gt;0) {
                  a =p;
                  FA = FP;
              } else {
                  b = p;
                  FB = FP;
              }
              i++;
          }
      }
  
      printf("The number of iterations is: %d\n", i);
  }
  </code></pre>