Hot answers tagged

1

The (only) else clause executes after the MASTERCARD code; if a card was already determined to be VISA or AMEX, it will not be MASTERCARD, therefore, will execute that else. In pseudo code something like this: IF card is VISA print VISA IF card is AMEX print AMEX IF card is MASTERCARD print MASTERCARD ELSE print INVALID Once it is ...


1

If you want to print something different based on a condition, you need to use a conditional like an if. As written this program will only ever output (sign) and 5 dashes. Full stop. This does not look like an exercise from CS50x (or CS50ap). This forum focuses specifically on CS50 If you want to work on your skills in the c programming language, CS50x on ...


1

Very often, a syntax error on an apparently correct line indicates the preceding line. It is complaining about the indent of the comment on the line before.


1

The error is created by the compiler finding an else clause without knowing the corresponding if (there has to be exactly one statement or code block in between). Use {} blocks with your if to conditionally execute several statements, and never ever place a semicolon behind your if condition, that's the empty statement, you essentially tell the compiler to ...


Only top voted, non community-wiki answers of a minimum length are eligible