0

I get 2 blank lines when I run my mario.c program before it outputs the pyramid for some reason which causes it not to pass check50. Why?

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

int printHashes(int number);
int h;
int hashes; 


int main(void) {

    do {
        printf("Height: ");
        h = get_int();

    }
    while(h < 0 || h > 23 );



    for(int i = 0; i <= h; i++) {



        for (int spaces = 0; spaces < h - i; spaces++) {

            printf(" ");

        }
        for (hashes = 0; hashes < i; hashes++){
            printf("#");
       }


        printf("  ");




        for (int h2 = 0; h2 < i; h2++){
            printf("#");
        }
        printf("\n");

    }    
    return 0;

}
1

when i = 0 (first loop) program prints 6 empty spaces and one new line which check50 doesn't want. You should get rid of that. Starting for loop i = 1 i think solve your problem

0

The last printf is the problem, surely you want to do

printf("\n")

You must log in to answer this question.

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