I'm getting some errors when I run my code through check50 such as
handles a height of 0 correctly,
handles a height of 1 correctly,
handles a height of 2 correctly,
handles a height of 23 correctly,
rejects a height of 24 correctly,
I don't understand the first 4 error messages and I don't think the last one is correct since the spec says
However, to make things more interesting, first prompt the user for the half-pyramid’s height, a non-negative integer no greater than 23
I thought this meant 23 was highest height I could make and 24 should be rejected.
Here is my code:
#include <cs50.h>
#include <stdio.h>
void PrintSpaces(int x);
void PrintHashes(int x);
int main(void)
{
int n = 0;
// prompts the user for the height of the pyramid //
do
{
printf("Give me a number between 1 and 23. This will be the height for the pyramid : ");
n = GetInt();
}
while (n < 1 || n > 23);
printf("Height = %d\n", n);
//Prints a number of spaces and hashes such that they add up to n on each line and form a half pyramid, with the most hashes on the bottom.
for(int i = 0; i < n; i++)
{
PrintSpaces(n - i - 1);
PrintHashes(i + 1);
}
}
void PrintSpaces(int x)
{
for (int b = 0; b < x; b++)
{
printf("%s", " ");
}
}
void PrintHashes(int x)
{
for (int b = 0; b < x; b++)
{
printf("%s", "#");
}
printf("\n");
}
enter preformatted text here