Algorithm Help

Homework Statement

In the given picture below

The Attempt at a Solution

Im stuck after the begin
How can I carry out the printSpaces(j+1) if the value of j wasn't given???

Is there an error in the question or is there something that im not seeing :/

Attachments

• 157.9 KB Views: 371

Related Engineering and Comp Sci Homework Help News on Phys.org
gneill
Mentor
Looks like an error in the given algorithm unless the language automatically initializes all new variables to zero (or some other specified value).

If not defining j was an oversight on the question composer's part then you might state some assumed value for it and proceed to solve the problem using that value.

Thanks man

So if I assume that j starts at 0 the output would be:

-*--------*
***********

gneill
Mentor
Thanks man

So if I assume that j starts at 0 the output would be:

-*--------*
***********
Looks right to me!

Thanks alot man