0

I've been stuck on the Mario.c problem and I really can't seem to understand how to print the # and spaces. So far, I understand the pattern formed but what am I doing wrong? Could someone please guide me through this problem? I attached my code below:

    #include <stdio.h>
#include <cs50.h>

/* height: 5    space + hash = height 
    #   hash: 1 s:4
   ##   
  ###
 ####
#####
*/


int main ()
{
int height, space, hash;
    do 
    {
        printf("Height of pyramid: \n");
        height= GetInt();
    }
    while ((height < 23) || (height > 0));
    for (hash=0, hash++);
    {
        printf("#");
    }
}
2

Your comments in the code show that you're close, but you don't quite understand the pattern requested. A hidden lesson of this pset is to learn to read and understand exactly and precisely what a program specification is asking you to do - nothing more and nothing less.

With that in mind, how many hashes are supposed to be in the first row? ;-)

Once you understand the pattern correctly, break the problem down into parts. Part 1 - get the height. 2. print out the correct number of rows. 3, print out the right number of hashes on each row. 4, add the spaces.

Get each part working before you move on to the next. You have a lot of work to do and need to at least try to get a working program.

If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)

1
  • Thank you for your help!!
    – rdp0821
    Jun 11 '16 at 20:54

You must log in to answer this question.

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