title: How can I filter out a value above 100 so that it doesn't puts it in the sum
body: <p>The program asks for input of the speed, when the speed is above 100 it should not include that value in the calculation of the average speed. How can I do that?</p>
  
  <p>I have put a i--; in the else if where it says else if(speed > 100). It repeats the question, but doesn't remove the value that is bigger than 100.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main(){
  
      int i;
      double speed, sum = 0.0;
      float average; 
  
      for( i = 0; i &lt; 10; i ++ ){ // asks 10 times the printf
          printf("%d Enter speed: ", i);
          scanf("%lf",&amp;speed); // saves the input speed
  
          sum += speed; // sum = sum + speed; 
  
          // decides which gear to use
          if (speed == 0){
              printf("gear N\n");
          }else if (speed &lt; 0 ){
              printf("gear R\n");
          }else if(speed &lt;= 10.0){
              printf("gear 1\n");
          }else if (speed &lt;= 30.0){
              printf("gear 2\n");
          }else if (speed &lt;= 60.0){
              printf("gear 3\n");
          }else if (speed &lt;= 80.0){
              printf("gear 4\n");
          }else if (speed &lt;= 100.0){
              printf("gear 5\n");
          }elseif (speed &gt; 100 ){ // when input higher than 100 dont save the input and ask again
              printf("max speed 100 km/h\n");
               i--;  
          }else 
              printf("Error!\n");
      }
  
      average = sum/i; // average calculation
  
      printf("average speed = %.2lf km/h", average); // prints out the average
  
      return(0);
  }
  </code></pre>
  
  <p>When I put 200 it should remove the value and ask again. What I'm getting when I put 200 it asks again but uses the 200 to calculate the average.</p>