// logical-AND, logical-OR, logical-NOT, eXclusive-OR (XOR) #include int main(void) { // assign values to variables int iaVar = 5; // true int ibVar = 20; // true // do the comparison if ( iaVar && ibVar ) printf("Logical_AND, both true: true\n" ); if ( iaVar || ibVar ) printf("Logical_OR, either one is true: true\n" ); // lets change the value of iaVar and ibVar iaVar = 0; // false ibVar = 10; // true // do the comparison if ( iaVar && ibVar ) printf("Logical-AND, both true: true\n" ); else printf("Logical_AND, either one is false: false\n" ); // negate if ( !(iaVar && ibVar) ) printf("Logical_NOT, !true: false\n" ); // more comparison if((10 > 20) && (3 < 7)) printf("Logical-AND, false && true: false\n"); // but if((10 > 20) || (3 < 7)) printf("Logical-OR, false || true: true\n"); if((4 > 1) && (7 > 6)) printf("Logical-AND, true && true: true\n"); // but if((4 > 1) || (7 > 6)) printf("Logical-OR, true || true: true\n"); // then if((10 > 20) ^ (3 < 7)) printf("X-OR, false ^ true: true\n"); // and if((3 < 7) ^ (10 > 20)) printf("X-OR, true ^ false: true\n"); // and if((9 < 7) ^ (10 > 20)) printf("X-OR, false ^ false: false\n"); // and if((3 < 7) ^ (30 > 20)) printf("X-OR, true ^ true: false\n"); return 0; }