Check-50 says trailing whitespace but i cant find the problem. Check50 and my output have the exact same output when counting the spaces.
My code:
#include <cs50.h>
#include <stdio.h>
void space(int length);
void hash(int length);
int n;
int main(void)
{
// asks the height
do
{
n = get_int("What is the height? ");
}
while (n < 1);
// loops the left facing pyramid
for (int j = 0; j < n; j++)
{
space(n - j - 1);
hash(j + 1);
}
printf("n");
}
// defines the spaces
void space(int length)
{
for (int i = 0; i < length; i++)
{
printf(" ");
}
}
// defines the hash part
void hash(int length)
{
for (int k = 0; k < length; k++)
{
printf("#");
}
printf("n");
}
Check 50
New contributor
Cr_tical is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.