1. Not finding help here? Sign up for a free 30min tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Algorithm Help

  1. Mar 19, 2014 #1
    1. The problem statement, all variables and given/known data
    In the given picture below


    3. 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 :/
     

    Attached Files:

  2. jcsd
  3. Mar 19, 2014 #2

    gneill

    User Avatar

    Staff: 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.
     
  4. Mar 19, 2014 #3
    Thanks man

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

    -*--------*
    ***********
     
  5. Mar 19, 2014 #4

    gneill

    User Avatar

    Staff: Mentor

    Looks right to me!
     
  6. Mar 19, 2014 #5
    Thanks alot man
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted



Similar Discussions: Algorithm Help
  1. Algorithm help (Replies: 1)

Loading...