#Error: Expected ')' before 'a'

13 messages · Page 1 of 1 (latest)

alpine bane
#

Here is the code:

    char buchstabe;
    int a;
    int b;

    printf("Folgende Wörter sind nutzbar:\n\nKälter\nWärmer\nSchulden");
    printf("Bitte geben sie die 1. Zahl ein: ");
    scanf("%d", &a);

    printf("Bitte geben sie die 2. Zahl ein: ");
    scanf("%d", &b);

    printf("Bitte geben sie die ersten buchstaben (K, W, S) ein: ");
    scanf(" %c", &buchstabe);

    switch(buchstabe) {
    case 'K':
    case 'k':
      printf("%d Celsius ist %d Celsius kälter.\nDadurch nehmen wir die Subtraktion." a, b, a-b);
      break;
    case 'W':
    case 'w':
      printf("%d Celsius ist %d Celsius wärmer.\nDadurch nehmen wir die Addition." a, b, a+b);
      break;
    case 'K':
    case 'k':
      printf("Mit Gehalt von %d muss Ich %d für die Schulden bezahlen" a, b, a-b);
      break;
    default:
        printf("Invalid. Mehr wird in der Zukunft gemacht!");
    }
}```

Ignore the German here. Basically this is a program which is supposed to take letters and make a sentence showing the user a calculation with word terms.

The Output is failure "Expected ')' before 'a". 
Idrk what I am supposed to use Paranthesis for but please help me on this one.
somber fernBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.

alpine bane
#

Btw it is line 128, which is printf("%d Celsius ist %d Celsius kälter.\nDadurch nehmen wir die Subtraktion." a, b, a-b);

next flame
#

put a comma after the format string, it's also an argument

#

also, you're passing in one argument too many

#

also you forgot to replace K with S

alpine bane
#

im not exactly sure what you mean by "format string", like format specifier "%d"?

next flame
#

the format string is the "%d Celsius ist %d Celsius kälter.\nDadurch nehmen wir die Subtraktion.", it contains format specifiers like %d
you need to put a comma after the format string because it's also an argument
and you need to have the same number of format specifiers as arguments after the format specifier, so, this is allowed:
printf("%d\n", 69);
while this isn't:
printf("%d\n", 69, 69);
printf("%d %d\n", 69);

alpine bane
#

Yep this worked .

#

Thank you so much

next flame
#

np

alpine bane
#

!solved