1

hey im having problems getting started with the mario pset. my code is below and i am getting these errors... any help would be so much appreciated thanks.

mario.c:16:5: error: expected expression else if (n > 0 && n < 9); ^ mario.c:18:26: error: more '%' conversions than data arguments [-Werror,-Wformat] printf("Stored: %i\n, n"); ~^ 2 errors generated.

code below

include

include

int main(void) { int n;

do
{
    n = get_int("Height: ");     //asks user for height of pyramid
}
while ((n < 1) || (n > 8));
{
    printf("try again");
}
else if (n > 0 && n < 9);
{
    printf("Stored: %i\n, n");
}

}

1 Answer 1

1

You can't use else if unless you used if statement first. That is the basic property of conditional statements.

You don't need to put an extra conditional loop. Computer is smart enough to know that if the prompted value is correct, move to next line of code.

You must log in to answer this question.

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