0

when I executed I have this errors:

:( handles a height of 1 correctly
    expected "# #\n", not "# #\n"
:( handles a height of 2 correctly
    expected " # #\n## ##\n", not " # #\n## ##\n"
:( handles a height of 23 correctly
    expected " ...", not " ..."
:( rejects a height of 24, and then accepts a height of 2
    expected " # #\n## ##\n", not " # #\n## ##\n"

My code here: int main(void) { int n; do { printf("Height: "); //user enter number concerning the piramid's height n = get_int(); } while (n < 0 || n > 23); for (int i = 0; i < n; i++) //count { for (int j = 0; j <= n - 1; j++) { if (i + j < (n - 1)) printf(" "); //insert spaces for left side's of piramid else printf("#"); //insert hashtags for left sides of piramid } printf(" "); //insert gaps for (int r = 0; r < i + 1; r++) //counter which creates right sides's of piramid { printf("#"); //insert hashtags for right sides of piramid } printf("\n"); //new line for next constructor side of piramid } return 0; }

What is wrong in this code?

1
  • When posting code here on Stack Exchange, you can select the code and click the {} button or press Ctrl+K to indent it by four spaces. Any block that has four spaces in front of all the lines is considered code, gets uniform grey background and if required scroll bars. Also, gets some colouring, as the formatter will guess the code's language.
    – Blauelf
    Commented Nov 14, 2017 at 10:23

1 Answer 1

1

Per the spec, the gap between the two sides should be 2 spaces. You've got one.

You must log in to answer this question.

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