0

Why does check50 keep returning errors ? My output is exactly, what's asked. What is it expecting? Moreover, what does it mean by exit code of 0?

I have tried several times.

check50 results Sandbox

#include<stdio.h>
#include<cs50.h>
int main(void)
{
    int i,j;

    CHECK:printf("Height:");
    int num=GetInt();
    if(num>0&&num<=23)
    {   printf("\n");

        for(i=1;i<=num;i++)
        {       
            for(j=1;j<num-i+1;j++)
            {
            printf(" ");
            }
            for(j=num-i;j<num;j++)
            {
            printf("#");
            }
        printf("#\n");
        }

    }
    else
    if (num==0)
    printf("\n 0");
    {
    goto CHECK;
    }

}
3
  • Can you show us your source code? – Mampoempan Aug 9 '15 at 14:18
  • Are you printing a newline at the end of the pyramid and then return 0? – ChrisG Aug 9 '15 at 17:08
  • Well it's not actualy a dupliacte as the pset is almost done, but it might help @saicharannivarthi solve his/her problem. – ChrisG Aug 10 '15 at 18:46
2

looks like you're using a GOTO statement do avoid that if you can my suggestion is to use a do while loop instand using a GOTO statement. you refer this code snippet but don't copy this code as it (it's not allowed in course's policy) do read that code and try to understand logic and write this in your own way.code snippet for reference

2

can't say anything without looking at code so please include code

but while looking at that sandbox link looks like you don't returning values that expected by check50 like this if program is given a height that is not valid you should return 1 (i am not sure check pset pdf for conformation) and that will terminate that program and if user input a valid height you should print that height (that you doing ) and return 0;

accept this answer if this answer answers your question

0

Not the answer you're looking for? Browse other questions tagged .