home *** CD-ROM | disk | FTP | other *** search
/ C by Discovery (4th Edition) / C_By_Discovery_4th_Edition.tar / C_By_Discovery_4th_Edition / _DISK_ / ch2 / relation.c < prev    next >
C/C++ Source or Header  |  2005-06-16  |  885b  |  27 lines

  1. /*                           relation.c
  2.  *
  3.  *   Synopsis  - Displays values of relational expressions.
  4.  *
  5.  *   Objective - To illustrate that relational expressions are
  6.  *               given the values of 1 for true and 0 for false.
  7.  */
  8.  
  9. /* Include Files */
  10. #include <stdio.h>
  11.  
  12. int main( void )
  13. {
  14.      int x = 3;
  15.                                                              /* Note 1 */
  16.      printf( "The value of (x == 3) is %d.\n", x == 3 );
  17.      printf( "The value of (x != 3) is %d.\n", x != 3 );
  18.  
  19.      printf( "The value of (3*x - 4 <= 3) is %d.\n", 3*x - 4 <=3 );
  20.      printf( "The value of (x >= 3) is %d.\n", x >= 3 );
  21.                                                              /* Note 2 */
  22.      printf( "The value of (2*x %% 3 > 3) is %d.\n", 2*x % 3 > 3 );
  23.  
  24.      printf( "The value of (25 / (2*x) < 3) is %d.\n", 25 /(2*x) < 3);
  25.      return 0;
  26. }
  27.