Solving Algorithm Homework: PrintSpaces(j+1) Error?

  • Thread starter Thread starter Ronaldo95163
  • Start date Start date
  • Tags Tags
    Algorithm
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
4 replies · 2K views
Ronaldo95163
Messages
77
Reaction score
1

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 I am not seeing :/
 

Attachments

  • trace.png
    trace.png
    70.9 KB · Views: 535
Physics news on Phys.org
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:

-*--------*
***********
 
Ronaldo95163 said:
Thanks man

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

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

Looks right to me!
 
Thanks a lot man