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

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

| improve this answer | |
1

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

| improve this answer | |
1

If I helped you be sure to tick the answer.

| improve this answer | |
  • Thanks man I got there lol – JFTrees Jun 19 at 9:09
  • No problem:) If you stuck at any point you can tell me. – Shahroz Ali Jun 19 at 9:28
  • 1
    This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. - From Review – MARS Jul 5 at 17:35

You must log in to answer this question.

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