1/* Test operators */ 2 3void testInc() { int a, b; a = 3; b = a++; printf("3++ = %d %d\n", b, a); } 4void testDec() { int a, b; a = 3; b = a--; printf("3-- = %d %d\n", b, a); } 5void testTimes(){ printf("%d * %d = %d\n", 10, 4, 10 * 4); } 6void testDiv(){ printf("%d / %d = %d\n", 11, 4, 11 / 4); } 7void testMod(){ printf("%d %% %d = %d\n", 11, 4, 11 % 4); } 8void testPlus(){ printf("%d + %d = %d\n", 10, 4, 10 + 4); } 9void testMinus(){ printf("%d - %d = %d\n", 10, 4, 10 - 4); } 10void testShiftLeft(){ printf("%d << %d = %d\n", 10, 4, 10 << 4); } 11void testShiftRight(){ printf("%d >> %d = %d\n", 100, 4, 100 >> 4); } 12void testLess(){ printf("%d < %d = %d\n", 10, 4, 10 < 4); } 13void testLesEqual(){ printf("%d <= %d = %d\n", 10, 4, 10 <= 4); } 14void testGreater(){ printf("%d > %d = %d\n", 10, 4, 10 > 4); } 15void testGreaterEqual(){ printf("%d >= %d = %d\n", 10, 4, 10 >= 4); } 16void testEqualTo(){ printf("%d == %d = %d\n", 10, 4, 10 == 4); } 17void testNotEqualTo(){ printf("%d != %d = %d\n", 10, 4, 10 != 4); } 18void testBitAnd(){ printf("%d & %d = %d\n", 10, 7, 10 & 7); } 19void testBitXor(){ printf("%d ^ %d = %d\n", 10, 7, 10 ^ 7); } 20void testBitOr(){ printf("%d | %d = %d\n", 10, 4, 10 | 4); } 21void testAssignment(){ int a, b; a = 3; b = a; printf("b == %d\n", b); } 22void testLogicalAnd(){ printf("%d && %d = %d\n", 10, 4, 10 && 4); } 23void testLogicalOr(){ printf("%d || %d = %d\n", 10, 4, 10 || 4); } 24void testAddressOf(){ int a; printf("&a is %d\n", &a); } 25void testPointerIndirection(){ int a, b; a = &b; b = 17; printf("*%d = %d =?= %d\n", a, * (int*) a, b); } 26void testNegation(){ printf("-%d = %d\n", 10, -10); } 27void testUnaryPlus(){ printf("+%d = %d\n", 10, +10); } 28void testUnaryNot(){ printf("!%d = %d\n", 10, !10); } 29void testBitNot(){ printf("~%d = %d\n", 10, ~10); } 30 31int main(int a, char** b) { 32 testInc(); 33 testDec(); 34 testTimes(); 35 testDiv(); 36 testMod(); 37 testPlus(); 38 testMinus(); 39 testShiftLeft(); 40 testShiftRight(); 41 testLess(); 42 testLesEqual(); 43 testGreater(); 44 testGreaterEqual(); 45 testEqualTo(); 46 testNotEqualTo(); 47 testBitAnd(); 48 testBinXor(); 49 testBitOr(); 50 testAssignment(); 51 testLogicalAnd(); 52 testLogicalOr(); 53 testAddressOf(); 54 testPointerIndirection(); 55 testNegation(); 56 testUnaryPlus(); 57 testUnaryNot(); 58 testBitNot(); 59 return 0; 60} 61