I am fairly confused with the Check50 results.
I seem to have written the correct code for this problem and all testing shows its working as intended. My code is below:
#include <cs50.h>
#include <stdio.h>
int main(void)
//get int from user, loop if its less than 1 or greater than 8
{
int h;
h=0;
do
{
h=get_int("Hight: ");
}
while(h<1||h>8);
//loops for both number of rows to print and the loops for spances (note the spaces decrease as h increase), #s, 2 spances and the rest of #s (both sets of # increase as h increase)
for (int a=1; a<=h; a++)
{
for (int r=0; r<h-a; r++)
{
printf(" ");
}
for (int r=0; r<a; r++)
{
printf("#");
}
printf(" ");
for (int r=0; r<a; r++)
{
printf("#");
}
//add a new line so each loop prints on differnt lines
printf("\n");
}
//one more new line before finishing
printf("\n");
}
However when checking via Check50, there are errors for all heights between 1-8. But the expected results and actual results looks identical to me.
Can someone tell me if I've gone wrong somewhere? Thank you so much.