What's wrong with this code in C++?
<pre><code>#include &lt;iostream&gt;
using namespace std;

int main()
{
    int i;
    int a[5];
    for (i=0; i&lt;5; i++) {
        cin&gt;&gt;a[i];
    }
    for (int j=0; j&lt;5; j++) {
        if (a[j] == 42) break;
        cout&lt;&lt;a[j];
    }
}
</code></pre>

<p>Simple program. Read an array of five numbers. Print the same array until the number 42, if it is entered. For some reason the output is all garbled.</p>
