title: How to add two arrays together in C++?
body: <p>I need to add two arrays together. Why does the following how work?</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  int main ()
   {   
          int sumvals[3];
          int nums[3];
  
          sumvals [0] = 1;
          sumvals [1] = 2;
          sumvals [2] = 3;
  
  
          for (i=0; i &lt;= 3; i++)
          {
            sumvals[i] = sumvals[i] + numbs [i];
            cout &lt;&lt; "the sum of the array elements is: " &lt;&lt; sumvals &lt;&lt; endl;
  
           }
  </code></pre>