Hey guys please tell me what is wrong with this syntax. I want the pyrmaid to work, the do while loop works like a charm.

  • If something is wrong with the syntax, you will see an error message that explains where the problem occurred. Please try to identify what part of your code is causing the problem, and if this doesn't help you to solve the error, describe the error for us in more detail. You can edit your question to add more information.
    – Air
    Aug 6 '14 at 17:33
  • This question appears to be off-topic because it is seeking debugging help.
    – user2173
    Aug 16 '14 at 18:00
  • Go listen to the video with Zamyla. The walk through. Apr 20 '15 at 19:39

You almost have the correct code to draw one line. Below are some suggestions of things to consider:

  1. Try get one line working first. Don't worry about doing all the lines at first. Once you can draw one line, then try doing multiples.
  2. Try using fixed values at first. So where you're calculating decrease, use a fixed number like 3. Try different values and observe the results.
  3. Your first for loop is correct.
  4. Your second for loop has the right idea, but it's not entirely correct.
    1. You only need to print one hash # in each iteration of the loop. You control the number of hashes by controlling the starting and ending values of the loop.
    2. Think about how many hashes should be on the first line. This is never less than 2. If the first line has two hashes ##, the second line 3 ###, the third line 4 #### and so on. There's a pattern.
  5. Your third loop is probably not doing what you intended.
  6. Once you can display one single line of spaces and hashes, then try repeat the line the number of times entered by the user. To do this, you would need to use a loop inside a loop - a "loopception" if you will. Here's an example of what this might look like:

    for (int i = 0; i < 5; i++) 
        for(int j = 0; j < 4; j++)       
        for(int j = 0; j < 3; j++)       

    Which outputs the following:


    Note that the inner loops use a different variable (j), to the outer loop (i).

  7. Don't forget to print the \n character at the end of each line.

  8. It may be hard to see it's printing the correct number of spaces, because you can't "see" spaces. Try using dashes or dots instead of spaces to test with, just until you get it working, then switch back to using spaces.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .