title: Skip for loop when if statement is met inside for loop
body: <p>I have an <code>if</code> statement inside a <code>for</code> loop. When the the condition in <code>if</code> statement is true, I want to break out of the <code>for</code> loop.</p>
  
  <p>here is what exactly I have </p>
  
  <pre><code>if (data &lt; voltage &amp;&amp; data2 &lt; voltage) {
  digitalWrite(pump, HIGH);
  digitalWrite(valve, HIGH);
  digitalWrite(valve2, HIGH);
  for (int i = 0; i &lt; 10; i++) {
    lcd.setCursor(0, 2);
    lcd.print("S_1:");
    if (data &gt; 260 &amp;&amp; data &lt; 295)
      lcd.print("MID");
    else if (data &lt; 260)
      lcd.print("LOW");
    else
      lcd.print("HIGH");
    lcd.setCursor(7, 0);
    lcd.print("Pump:ON");
    lcd.setCursor(0, 1);
    lcd.print("V1:ON");
    lcd.setCursor(9, 2);
    lcd.print("S_2:");
    if (data2 &gt; 260 &amp;&amp; data2 &lt; 295)
      lcd.print("MID");
    else if (data2 &lt; 260)
      lcd.print("LOW");
    else
      lcd.print("HIGH");
    lcd.setCursor(7, 1);
    lcd.print("V2:ON");
    lcd.setCursor(14, 1);
    lcd.print("V3:OFF");
    sum += data;
    sum2 += data2;
    delay(1000);
  }
  average = sum / 10;
  average2 = sum2 / 10;
  if (average &gt; voltage || average2 &gt; voltage) {
    digitalWrite(pump, LOW);
    digitalWrite(valve, LOW);
    digitalWrite(valve2, LOW);
  }
  sum = 0;
  sum2 = 0;
  lcd.clear();
  }
  </code></pre>
  
  <p>It seams not going throw the whole conditions.</p>