-1

I can get the users input but i cant print the pyramid. i can only get the spaces on the first line. Plus this is the same part that i got stuck on last year and i am only 13.

7
  • Considering your age, this question may be genuine for you, but not healthy for this site. I am voting to close this question, but for sure [facebook.com/groups/cs50/](facebook group) or stackexchange chat rooms would help you.
    – sinister
    Apr 17 '15 at 17:38
  • Isaac, I think you are asking a fair question. The reason for this forum is to help people break through when they have problems with coding, especially if they have made an effort to work on it. It's especially important to help younger people trying to learn to program. However, we'll need some more details to help you. Can you describe what you think is happening? What do you think it is really doing and how is that different from what you want it to do? Don't post your whole code, but please post the part that you think is not working right.
    – Cliff B
    Apr 17 '15 at 18:06
  • Also, please copy the output that the program is generating, if you can, or tell us that it is nothing but spaces. Have you tried putting in some extra print lines in your program for testing? You can always take them out once it is running right. Print out the user input to make sure you have it right. Try changing the spaces to 'x' to see that they really are printing. Are you using for loops? Put a print line in it to print out the control variable to see how often it runs. ( for (x=0; x<4;x++) { print("x=%i \n", x); } ) Maybe do these and show the output when you reply.
    – Cliff B
    Apr 17 '15 at 18:09
  • Also, instead of replying with more comments, edit your question so that you can post more, or better yet, delete this one yourself and start a new, more complete question. We WILL help you!
    – Cliff B
    Apr 17 '15 at 18:10
  • 1
    Don't use your age as an excuse! People like Persson, Gates, and Zuckerberg did not use their age to define how good they are. Anyways, the best recommendation to solve this, and future problems easier is to take down as many notes as you can.
    – BooFluff
    May 19 '15 at 2:00
0

Think of the pyramid as a huge grid e.g. 5x5. If you noticed, the spaces start with 2 less than the top row of the pyramid. The # start with 2. Then, every time, the number of spaces decreases by one, and # increases by one until it hits the max.

Just like in Scratch, you will surround all of the math with forever loops.

Some codes you should know is (enter variable here)++, for (enter conditions), <, >, and %s.

Here are the steps that I took

Define Variables, e.g. user input and function variable
If Variable is less than 0, then re-prompt the user with do, while loops
Loop (the function can not be greater than the input, and the function is being added one every time).
{Then, use the observations of the patterns of a pyramid to figure out the rest}(Notice how there are spaces before hashes)

You must log in to answer this question.

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