I have written the code that makes the pyramid exactly how I am supposed to make it look. When I try it on my local computer, it works, but check50 doesn't agree. check50 displays "timed out while waiting for program to exit" message. How do I fix this? Here is my code and a picture to show the messages.
#include <cs50.h>
#include <stdio.h>
void hash(int z);
void space(int y);
int main(void)
{
// get height
int n;
do
{
n = get_int("Height: ");
}
// make sure height is in the range of 4-8
while (n < 4 || n > 8);
// repeat height times
for (int i = 0; i < n; i++)
{
int s = n - 1 - i;
// Repeat height - i times (writes spaces)
space(s);
// Repeat i times (writes #'s)
hash(i + 1);
// The break in the ramps
printf(" ");
// Repeat i times (writes #'s again
hash(i + 1);
// Line break
printf("\n");
}
}
void hash(int z)
{
for (int x = 0; x < z; x++)
{
printf("#");
}
}
void space(int y)
{
for (int j = 0; j < y; j++)
{
printf(" ");
}
}