/***************************************************************************
 *  Columbia University Introduction to Computer Programming in C COMS 1003
 *  Example for boolean expressions
 *
 *  Copyright (C) 2005 Michael E. Locasto
 *
 *  All rights reserved.
 *
 * $Id: boolexp.c,v 1.1 2005/09/27 02:55:19 locasto Exp $
 **************************************************************************/

#include <stdio.h>

/**
 * This program demonstrates making choices based on the value
 * of boolean expressions. It also demonstrates printing a 
 * simple truth table.
 */
int main(int argc, char* argv[])
{
   int p = 1; //true
   int q = 0; //false

   printf("p AND q = ");
   if(p&&q)
   {
      printf("true\n");
   }else{
      printf("false\n");
   }

   printf("%2c | %2c || %5s\n", 'P', 'Q', "P OR Q");
   printf("-----------------\n");
   for(p=1;p>=0;p--)
   {
      for(q=1;q>=0;q--)
      {
         printf("%2d | %2d || %5d\n", p, q, p||q);
      }
   }

   return 0;
}
