0
int main(void)
{
    int original_height, var_height;    // original height and variable height
    int row_position;

    do
    {
        printf("height: ");
        original_height = GetInt();     //prompt user for input until the value is acceptable
        var_height = original_height;
    }
    while((original_height < 0) || (original_height > 23));

    if(original_height > 0)
    {
        printf("\n");
        while(var_height > 0)
        {
            for(int i = 0; i<(var_height-1) ;i++)   // spaces for single row (left)
            {
                printf(" ");
            }
            for(row_position = (var_height-2); row_position < (original_height - 1); row_position++)    // hashes for single row(left)
            {
                printf("#");
            }
            printf("  ");
            for(row_position = (var_height-2); row_position < (original_height - 1); row_position++)    // hashes for single row(right)
            {
                printf("#");
            }
            for(int i = 0; i<(var_height-1) ;i++)   // spaces for single row(right)
            {
                printf(" ");
            }
            printf("\n");
            var_height -=1;
        }
    }
}

https://sandbox.cs50.net/checks/a692a92e704f474cbe73eeb5439f906b

1
  • Apologies if the post is not well made, it is my first one. I can't seem to understand what I'm doing wrong here? The output looks exactly the same. I have also included a new line character based on other issues i've read. Any one have any suggestions?
    – He-lion
    Jun 16, 2017 at 15:46

1 Answer 1

1

Not having count the elements, I can say based on own experience that there should be no spaces at the end of the lines. So remove your last loop and you should be fine.

1
  • Thank you! By reading your comment I understand that the spaces after the hashes on the right pyramid are not needed.
    – He-lion
    Jun 16, 2017 at 16:08

You must log in to answer this question.

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