title: Group sum of n consecutive numbers of array
body: <p>So I have an array like <code>{1, 4, 2, 3, 5, 3, 7}</code> and I have to make a new array containing the sums of each 3 consecutive elements like <code>{7, 9, 10, 11, 15}</code>.
  So far I got here and I don't know what I'm doing wrong.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;conio.h&gt;
  
  using namespace std;
  
  int a[] = {1, 1, 2, 3, 5, 3, 7};
  int lung = sizeof(a)/sizeof(a[0]);
  int *l = new int[10];
  
  int calc(int *a, int m)
  {
      int sum = 0;
      int stmax = (lung - m) - 1; 
      for(int st=0;st &lt;= stmax; st++)
      {
          for(int i = 0; i &lt; m; i++)
          {
              sum = sum + a[st+i];
          }
          l[st] = sum;
      }
      return 0;   
  }
  
  void main()
  {
      int a[] = {1, 1, 2, 3, 5, 3, 7};
      cout &lt;&lt; calc(a, 3)&lt;&lt; endl;
      for (int i = 0; i &lt; lung; i++)
      {
          cout &lt;&lt; l[i] &lt;&lt; " | ";
      }
      _getch();
  }
  </code></pre>