-6

In the 8th line below, I get a compiler error that says:

Expected primary expression before token ")"

What does it mean, and what is the mistake? I'm new to this, so please help!

float a,b,c;
printf("side1=");
scanf("%f",&a);
printf("side2=");
scanf("%f",&b);
printf("side3=");
scanf("%f",&c);
((a||b||c||)!=0&&(a+b)>c&&(b+c)>a&&(a+c)>b)?printf("Triangle"):printf("NOT a TRIANGLE");
getch();
Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
  • 4
    It means the parser found a `)` where it can't appear. The error message also gives the exact location of the offending token. – chris Mar 23 '18 at 04:49
  • 1
    `(..c||)`, you probably want to remote `||` after `c` – Gilles Gouaillardet Mar 23 '18 at 04:55
  • While true you can use the ternary operator, it's better in this particular case to use an `if-else` instruction for better readability. – Xam Mar 23 '18 at 05:07
  • Possible duplicate of [The Definitive C++ Book Guide and List](https://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list) –  Mar 23 '18 at 05:08
  • `((a||b||c||)!=0&&(a+b)>c&&(b+c)>a&&(a+c)>b)?printf("Triangle"):printf("NOT a TRIANGLE");` -- I guess this is your entry to the obfuscated `C` contest. – PaulMcKenzie Mar 23 '18 at 05:30
  • @Noshwin If you are stuck with errors in complex code lines try to reduce complexity. E.g. move the large expression into a dedicated line (bool is_triangle = ((a||...) and use this in the ternary operator (?:) – Jens Mar 23 '18 at 06:16
  • use` ( (a !=0) && (b !=0) && (c !=0) )` instead of `a||b||c||)!=0` –  Mar 23 '18 at 06:59

1 Answers1

-1

If you are checking for a OR b OR c then it should be a||b||c not a||b||c||.