title: Array Multiplication in c++
body: <p>This is homework.</p>
  
  <p>I am trying to multiply the <code>a</code> and <code>b</code> array together using this formula:</p>
  
  <pre><code>c[0]=a[0]*b[0]+a[0]*b[1]+a[0]*b[2]+....a[0]*b[n-1]
  
  c[1]=a[1]*b[1]+a[1]*b[2]+a[1]*b[3]+....a[1]*b[n-1]
  </code></pre>
  
  <p>and so on...</p>
  
  <p>But this code seems to only run through the <code>a</code> array but never through the <code>b</code> array. The results I get look this:</p>
  
  <pre><code>6
  12
  18
  9
  6
  15
  </code></pre>
  
  <p>Any pointers would be greatly appreciated.</p>
  
  <p>My code - </p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  const int n=6;
  int main()
  {
  
  int a[n]= {2,4,6,3,2,5};
  int b[n]= {3,2,1,4,2,3};
  int c[n];
  
  for (int h=0; h&lt;n; h++)
  {
      for (int g=0; g&lt;n; g++)
      {
          c[h] = a[h]*b[g];
      }
  }
  
  for (int i=0; i&lt;n; i++)
  {
      cout &lt;&lt; c[i] &lt;&lt; endl;
  }
  }
  </code></pre>