0

I am having trouble with check50 in pset1 more mario. Below as follows is my code, it works. Yet, for some reason it is invalid. I know it is wrong to post my entire code but I am stumped.

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

void repeat_print(char output, int limit);
void print_pyramidise(char primary, char secondary, int height);

int main(void)
{   
    int height;
    do
    {
        printf("Height: ");
        height = get_int();
    }
    while (height > 23 || height < 0);
    printf("\n");
    print_pyramidise('#', ' ', height);

}

void print_pyramidise(char primary, char secondary, int height)
{
    for (int i = 1; i <= height; i++)
    {
        repeat_print(secondary, height - i);
        repeat_print(primary, i);
        printf("  ");
        repeat_print(primary, i);
        printf("\n");
    }
}

void repeat_print(char output, int limit)
{
    for (int i = 0; i < limit; i++)
            printf("%c", output);
}
0

One of the hidden lessons of the first few psets is that the code must be written to exactly match the program specification. Anything extra or missing, including chars, spaces, line feeds, whitespace, prompts, or anything else, will cause a fail.

Having said that, how many #'s are supposed to be on the first line?

Also, it would have been even more helpful to have posted the output from check50.

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

You must log in to answer this question.

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