0

ok... I know this is a highly asked question and there are so many people that give advice but I still have not found what I am looking for. I have the prompt part done, I even have the spaces working... I can not figure out why my "#" are not working right.

Height of 5:

4 -'s 2 #'s line 0; 3 -'s 2 #'s line 1; 2 -'s 2 #'s line 2; 1 -'s 2 #'s line 3; 0 -'s 2 #'s line 4;

I have tried manipulating the hash for loop and I can get it to print 6 hashes but it will print them for every line.

this is what I have for my loop:

    for (hash = height; hash <= height + 1; hash++)
    {
        printf("#");
    }

hash is int at zero.

Any advice would be awesome because I have spent many hours reading, watching video's. I know messing with it teaches you but I'm seriously at a loss and have no one where I am that I can talk to about this.

1

You're on the right track. In fact, most of your code is right on target. The problem you are having is with the limit on how many hashes to print.

Currently, you control the number of hashes printed based on the TOTAL number of lines. Think about it, the number of hashes is based not on the total number of lines, but on which line you are on. No matter how high the pyramid is, you print 2 #s on the first line, 3 on the 2nd, 4 on the 3rd, etc. Do you see a pattern? I'll let you figure out the formula and the code, but this should get you going.

If this answers your question, please accept this answer to remove the question from the unanswered question pool. Let's keep up on forum housekeeping. ;-)

1
  • I got it... Figured it out before seeing your answer but your answer is legit... had to draw out line by line as I read the code, not pre draw what I want and find a pattern but how the computer would print my stuff... the issue was I had hashes <= a CONSTANT variable not a CHANGING variable... ty for the reply though! :)
    – Bo Hogg
    Jul 4 '15 at 21:35

You must log in to answer this question.

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