/* * ISA 563, Spring 2011 * Copyleft by Muhammad Abdulla */ #include /** * bittest.c -- demonstrates the differences between logical and bitwise operations */ int main(int argc, char* argv[]) { int x = 1; int y = 2; // Logical OR. Evaluates to true (1) if either one of the expressions is true (non-zero). int r = x || y; printf("r is: %d\n",r); // Bitwise OR. "OR"ing is applied to each pair of corresponding bits r = x | y; printf("r is: %d\n",r); // Logical AND. Evaluates to true (1) if both of the expressions are true (non-zero). r = x && y; printf("r is: %d\n",r); // Bitwise AND. "AND"ing is applied to each pair of corresponding bits r = x & y; printf("r is: %d\n",r); return 0; }