C | Operators | Question 11

filter_none

edit
close

play_arrow

link
brightness_4
code

#include <stdio.h> 
int main() 
  int a = 10, b = 20, c = 30; 
  if (c > b > a) 
    printf("TRUE"); 
  else
    printf("FALSE"); 
  return 0; 
}

chevron_right


(A) TRUE
(B) FALSE
(C) Compiler Error
(D) Output is compiler dependent


Answer: (B)

Explanation: Let us consider the condition inside the if statement. Since there are two greater than (>) operators in expression “c > b > a”, associativity of > is considered. Associativity of > is left to right. So, expression c > b > a is evaluated as ( (c > b) > a ) which is false.



My Personal Notes arrow_drop_up


Article Tags :
Practice Tags :


2


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.