Array/Pointer confusion
<p>Why does the following code print out <code>"0 0 0 0 0 0 0 "</code>? I was expecting <code>"1 3 6 10 15 21 28 "</code>. </p>

<pre><code>#include &lt;iostream&gt;

using namespace std;

void PrefixSum(float * input, float * output, int n){
    float sum = 0;
    for (int i=0;i&lt;n;i++){
        float value = input[i];
        sum += value;
        output[n] = sum;
    }    
}


int main(int argc, const char * argv[])
{
    float input[] = {1,2,3,4,5,6,7};
    float output[] = {0,0,0,0,0,0,0};
    PrefixSum(input, output, 7);
    for (int i=0;i&lt;7;i++){
        cout &lt;&lt; output[i] &lt;&lt; " ";
    }
    return 0;
}
</code></pre>
