int main() {
printf("=== Comparison Operators Tests ===\n");
int a = 10;
int b = 20;
int c = 10;
printf("Test 1: Less than (<)\n");
if (a < b) {
printf("10 < 20 = true\n");
}
if (b < a) {
printf("20 < 10 = true (SHOULD NOT PRINT)\n");
} else {
printf("20 < 10 = false\n");
}
if (a < c) {
printf("10 < 10 = true (SHOULD NOT PRINT)\n");
} else {
printf("10 < 10 = false\n");
}
printf("PASS: Less than operator works\n");
printf("Test 2: Greater than (>)\n");
if (b > a) {
printf("20 > 10 = true\n");
}
if (a > b) {
printf("10 > 20 = true (SHOULD NOT PRINT)\n");
} else {
printf("10 > 20 = false\n");
}
if (a > c) {
printf("10 > 10 = true (SHOULD NOT PRINT)\n");
} else {
printf("10 > 10 = false\n");
}
printf("PASS: Greater than operator works\n");
printf("Test 3: Less than or equal (<=)\n");
if (a <= b) {
printf("10 <= 20 = true\n");
}
if (a <= c) {
printf("10 <= 10 = true\n");
}
if (b <= a) {
printf("20 <= 10 = true (SHOULD NOT PRINT)\n");
} else {
printf("20 <= 10 = false\n");
}
printf("PASS: Less than or equal operator works\n");
printf("Test 4: Greater than or equal (>=)\n");
if (b >= a) {
printf("20 >= 10 = true\n");
}
if (a >= c) {
printf("10 >= 10 = true\n");
}
if (a >= b) {
printf("10 >= 20 = true (SHOULD NOT PRINT)\n");
} else {
printf("10 >= 20 = false\n");
}
printf("PASS: Greater than or equal operator works\n");
printf("Test 5: Negative number comparisons\n");
int neg1 = -5;
int neg2 = -10;
if (neg1 > neg2) {
printf("-5 > -10 = true\n");
}
if (neg2 < neg1) {
printf("-10 < -5 = true\n");
}
if (neg1 < 0) {
printf("-5 < 0 = true\n");
}
printf("PASS: Negative number comparisons work\n");
printf("Test 6: Comparisons in expressions\n");
int result = a < b;
printf("result of (10 < 20) = %d\n", result);
int result2 = a > b;
printf("result of (10 > 20) = %d\n", result2);
printf("PASS: Comparisons as expressions work\n");
printf("\n=== All Comparison Operators Tests Completed ===\n");
return 0;
}