-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
  • 755
  • 1
  • 12
  • 25

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
  • 104,019
  • 25
  • 176
  • 264
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,703
  • 33
  • 29
  • 42