home *** CD-ROM | disk | FTP | other *** search
/ C Programming Starter Kit 2.0 / SamsPublishing-CProgrammingStarterKit-v2.0-Win31.iso / tyc / list4_6.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-10-16  |  635 b   |  23 lines

  1.    #include <stdio.h>
  2.  
  3.    /* Initialize variables. Note that c is not less than d, */
  4.    /* which is one of the conditions to test for. */
  5.    /* Therefore the entire expression should evaluate as false. */
  6.  
  7.    int a = 5, b = 6, c = 5, d = 1;
  8.    int x;
  9.  
  10.   main()
  11.   {
  12.       /* Evaluate the expression without parentheses */
  13.  
  14.       x = a < b || a < c && c < d;
  15.       printf("\nWithout parentheses the expression evaluates as %d", x);
  16.  
  17.       /* Evaluate the expression with parentheses */
  18.  
  19.       x = (a < b || a < c) && c < d;
  20.       printf("\nWith parentheses the expression evaluates as %d", x);
  21.       return 0;
  22.   }
  23.