/* oddEven.c  P. Conrad  9/17/04 for CISC105 */
/* demonstrate % operator for odd/even and if/else */


#include <stdio.h>

int isOdd(int x)
{
  return (x%2);
}

  /* if x%2 is zero, then return x%2, because zero represents false
                     and if x%2 is zero, then the number is even,
                     so isOdd should be false */

  /* if x%2 is odd, then x%2 will be either 1 or -1.  In both cases,
                    any number that is NON ZERO represents TRUE in C.
                    So, return x%2.  If that number is non zero, that 
                    represents true, and isOdd should be true */ 



int main(void)
{
  int someNumber;

  /* prompt for input */

  printf("Please enter an integer: ");
  scanf("%d",&someNumber);

  /* provide output */

  if (isOdd(someNumber))
    printf("%d is odd.\n",someNumber);
  else
    printf("%d is even.\n",someNumber);

  return 0; /* tells unix that the program completed successfully */

}
  

