title: C++ how to print the first 10 and last 10 elements of an array?
body: <p>im trying to print the first 10 and the last 10 elements of an array. My attempt below returns the following in an infinite loop</p>
  <pre><code>Word: Count 0
  </code></pre>
  <pre><code>void printarrayString(std::string arr[], int size)
  {
      int i;
      int j;
  
      std::cout &lt;&lt; &quot;***first 10 elements***&quot; &lt;&lt; std::endl;
      for (i = 10; i &lt; size; i++)//print first 10 elements 
      std::cout &lt;&lt; &quot;Word: &quot; &lt;&lt; wordArr[i] &lt;&lt; &quot;  &quot; &lt;&lt; &quot;Occurs: &quot; &lt;&lt; countArr[i] &lt;&lt; std::endl;
      std::cout &lt;&lt; std::endl;
      
      std::cout &lt;&lt; &quot;***last 10 elements***&quot; &lt;&lt; std::endl;
      for(j = 10; j &lt; size-10; j-- ) //print last 10 elements
      std::cout &lt;&lt; &quot;Word: &quot; &lt;&lt; wordArr[i] &lt;&lt; &quot;  &quot; &lt;&lt; &quot;Occurs: &quot; &lt;&lt; countArr[i] &lt;&lt; std::endl;
      std::cout &lt;&lt; std::endl;
  }
  </code></pre>
  <p>How can i fix the loops so loop 1 prints the first 10 elements of wordArr and countArr and loop 2 prints the last 10 elements? Thankyou</p>