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?
{}
button or pressCtrl
+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.