-1
#include <stdio.h>

int main() {
int a = 10, b = 20, c = 30;
if (c > b > a)
    printf("TRUE");
else
    printf("FALSE");
return 0;
}

What happens at if(c>b>a), i know this works like if((c>b)>a),but why then false?

Gopal Sharma
  • 715
  • 1
  • 15
  • 24

3 Answers3

4

Operator > is left associative therefore c > b > a will be parenthesize as ((c > b) > a) . Since 30 is greater than 20, c > b = 1. So,

 (c > b) > a => (1 > a) => 1 > 10 => false
haccks
  • 100,941
  • 24
  • 163
  • 252
1

c>b evaluates to 1, which is not greater than 10.

drewbarbs
  • 345
  • 3
  • 9
1

c > b > a means

(c > b) > a which is false in your case..

Raghu Srikanth Reddy
  • 2,673
  • 33
  • 28
  • 41