Michlerish Michlerish - 4 months ago 16
C Question

Errors: expected ';' after expression and expression result unused

Why am I getting the errors of

"expected ';' after expression
, and
expressions result unused
? Here is my code:

#include <cs50.h>
#include <stdio.h>

int main(void)
{
printf("How tall do you want your pyramid to be?\n");
int height = GetInt();

if (height > 23 && height < 1)
{
printf("Please use a positive number no greater than 23:\n");
}
else (height > 0 && height <= 23)
{
printf("Thanks!\n");
}
}

Answer

There is no such things as

else (height > 0 && height <= 23)

else means everything else, so you can't give else a condition. Use else if instead ^^