Hi, I know it's probably a rookie mistake but I just can't seem to figure out why the integer i won't count up until it is equal with the integer pennies". Thanks for any help!
1 2 3 4 5 6 7 8
cout << "Please enter how many pennies you would like there to be in the pile?"<<endl;
cin >> pennies;
for(i = 0;i == pennies;i++)
{
cout << "O";
}
The middle condition is "while true", not a stopping condition. Unless 'pennies' is zero, it won't even start the loop. You'll have to use "i != pennies" instead.
If you're in doubt, try rewriting it as a while loop:
1 2 3 4 5 6 7 8 9
for (A; B; C) {
D;
}
// Is equivalent to
A;
while (B) {
D;
C;
}
As the 'while' is less confusing (put it into words if needed!), it's much easier to get the correct form.