0

Stuck on Pset 1 - drawing the pyramid (prompting the user for a number between 0 and 23 working fine).

When I try to execute this program, it goes crazy- is there something wrong with my for loops?

Thank you!

enter image description here

1 Answer 1

0

spaces-- will decrement spaces, so spaces < height - row - 1 will stay true until the integer does an overflow (going from least possible value to highest possible value by subtraction of one).

You probably meant spaces++.

Usually, if you don't care for the exact value of the counter (or one of these happens to be fine for you), you'd pick your loop either as

for (int counter = 0; counter < repetitions; counter++)

or

for (int counter = repetitions; counter > 0; counter--)

as both clearly show the number of repetitions.

The comparison operator should match the direction of the counter.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .