Logical operator precedence
Posted by JanWan
Last Updated: March 05, 2012
#include <stdio.h>

/* Initialize Variable. Note that c is not less than d, */
/* which is one of the conditions to be test for*/
/* Therefore, the entire expression should evaluate as false. */

int a = 5, b =6, c = 5, d = 1;
int x;

main ()
{
/* Evaluate the expression without parentheses */
x = a < b || a < c && c < d;
printf("\nwithout parentheses the expression evaluate as %d", x);
/* Evaluate the expression with parentheses */
x = (a < b || a < c) && c < d;
printf("\nWith parentheses the expression evaluate as %d\n", x);
return 0;
}