title: Select every 3 consecutive elements from an array and comparing them using a function
body: <pre><code>#include &lt;iostream&gt;
  using namespace std;
  // function to compare the three values
  int maximum(int x, int y, int z) 
  {
      int max;
      if (x &gt; y) {
          max = x;
          if (z &gt; max)
              max = z;
  
      } else {
          max = y;
          if (z &gt; max)
              max = z;
  
      }
      return max;
  }  
  // main code
  
  int main() {
  
      int i, a, b;
      cout &lt;&lt; "La dimension de la table?" &lt;&lt; endl; 
  
      // Ask user to select the size of the array, maximum 20. "a" is the size 
      cin &gt;&gt; a;
      while (a &gt; 20) {
          cout &lt;&lt; "La dimension maximum est 20! Reessayez!" &lt;&lt; endl;
          cin &gt;&gt; a;
      }
  
      int v1[a];
  
      // ask user to fill the array
      cout &lt;&lt; "Remplisez la table" &lt;&lt; endl;
      for (i = 0; i &lt; a; i = i + 1) {
          cin &gt;&gt; v1[i];
      }
      // using this variable to know when the loop should stop
      b = 0; 
      // selecting the 3 consecutive elements to compare
      while (b &lt;= a) {
          for (i = b; i &lt; 4; i = i + 1) { 
           // this is were it should compare the 3 selected values and print them
              cout &lt;&lt; "Le maximum est " &lt;&lt; maximum(v1[i], v1[i], v1[i]) &lt;&lt; endl; 
          }
          // passing to the next 3 values
  
          b = b + 3; 
      }
  }
  </code></pre>
  
  <p>This is my complete code. Everything works just fine except the last part where I have to select the values somehow and send them to the function to be compared. Any sugestions?</p>
  
  <p>Thanks alot!</p>