How does printSpaces(j+1) work without j being defined?

  • Thread starter Ronaldo95163
  • Start date
  • Tags Tags
    Algorithm
4 replies · 2K views · last reply
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
  • Printed exam question (b) with pseudocode: SIZE = 10, a while loop over j from 10 down, using printSpaces, print, println, then a for loop printing stars and a final println, asking for the output drawn.
    trace.png
    70.9 KB · Views: 558
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!