title: adding a second function to the array that is working with indexes of array
body: <p>I have a code that works perfectly, its finding average of all numbers that were put in the array and its finding average of a section of array. I just need to make second function that is working with the array with its indexes.</p>
  <p>Code:</p>
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  double priemer(double *pole, int dlzka);
  
      int main()
      {
          int i, dlzka;
          printf(&quot;Zadaj velkost pola: &quot;);
          scanf(&quot;%d&quot;, &amp;dlzka);
          while (dlzka &lt; 1)
          {
              printf(&quot;Chyba! Cislo musi byt viac, ako 0.\n&quot;);
              printf(&quot;Zadaj pocet prvkov znova: &quot;);
              scanf(&quot;%d&quot;, &amp;dlzka);
          }
          double *pole = malloc(dlzka * sizeof(double));
          for(i = 0; i &lt; dlzka; i++)
          {
              printf(&quot;cislo %d: &quot;, i + 1);
              scanf(&quot;%lf&quot;, &amp;pole[i]);
          }
          printf(&quot;Priemer vsetkych prvkov v poli je: %.3lf\n&quot;, priemer(pole, dlzka));
          int zaciatok, koniec;
          printf(&quot;Zadaj zaciatok useku: \n&quot;);
          scanf(&quot;%d&quot;, &amp;zaciatok);
          printf(&quot;Zadaj koniec useku: \n&quot;);
          scanf(&quot;%d&quot;, &amp;koniec);
          if(koniec &gt; dlzka || zaciatok &gt; koniec || zaciatok &lt; 1)
          {
              printf(&quot;Zly vstup&quot;);
              return 1;
          }
          printf(&quot;Priemer od %d. do %d. prvku je: %.3lf\n&quot;, zaciatok, koniec, priemer(pole + (zaciatok - 1), koniec - (zaciatok - 1)));
          return 0;
      }
      
      double priemer(double *pole, int dlzka)
      {
          double sum = 0;
          int i;
          for(i = 0; i &lt; dlzka; i++)
          {
              sum += pole[i];
          }
          return sum/dlzka;
      }
  </code></pre>