Open In App

C | Operators | Question 11

Last Updated : 10 Nov, 2020
Like Article
Like
Save
Share
Report




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


(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 the 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 ). And since the (c > b) is being the relational operator it will return 1 if True otherwise 0 is if False. So here the value returned is 1 and then it is compared to the a. so now, the statement becomes, (1 > a), which is false, so the answer, return is 0, therefore, else part is executed.

Quiz of this Question


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads