You only fill exercise[0]. Perhaps this would work better for you:
for (i = 0; i < 5; i++)
{
cin >> exercise[i];
cout << exercise[i] << endl;
}
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
>but my professor didn't explain it very well in class last night
How about you try to explain it to me as you understand it, then I'll fill in the blanks for you.
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
>using namespace std; // out of place
Actually, that's a better place than your proposed solution. The effect of a using directive is limited by scope. When you restrict the directive to a block scope, you minimize the chances of a name collision and effectively remove the biggest reason for avoiding the using directive[1].
>// C++ arrays start with index 0, so its 0, 1, 2, 3, 4
I think it's safe to say that the OP already understands this. :icon_rolleyes:
[1] The reason: a using directive at global scope defeats the purpose of namespaces. The only reason you should have a using directive at global scope is when porting pre-standard C++ quickly. In new code, it's a bad practice.
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401