• Support PF! Buy your school textbooks, materials and every day products Here!

Algorithm Help

  • #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 im not seeing :/
 

Attachments

Answers and Replies

  • #2
gneill
Mentor
20,714
2,715
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.
 
  • #3
Thanks man

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

-*--------*
***********
 
  • #4
gneill
Mentor
20,714
2,715
Thanks man

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

-*--------*
***********
Looks right to me!
 
  • #5
Thanks alot man
 

Related Threads for: Algorithm Help

  • Last Post
Replies
1
Views
1K
  • Last Post
Replies
1
Views
2K
Replies
2
Views
884
Replies
0
Views
3K
  • Last Post
Replies
7
Views
2K
  • Last Post
Replies
0
Views
1K
  • Last Post
Replies
2
Views
1K
Top