└── CT 1.c /CT 1.c: -------------------------------------------------------------------------------- 1 | #include 2 | //RA2111027010043 3 | int main() 4 | { 5 | int a = 10,b = 15, result; 6 | //Arithmetic operator 7 | result = a+b; 8 | printf("Addition: a+b = %d \n",result); 9 | result = a-b; 10 | printf("Subtraction: a-b = %d \n",result); 11 | result = a*b; 12 | printf("Multiplication: a*b = %d \n",result); 13 | result = a/b; 14 | printf("Division: a/b = %d \n",result); 15 | result = a%b; 16 | printf("Modulo Division: %d \n",result); 17 | result = ++a; 18 | printf("Increment the value of a by 1: %d \n",result); 19 | result = --b; 20 | printf("Decremented the value of b by 1: %d \n",result); 21 | // Relational operator 22 | //RA2111027010043 23 | int s = 6, t = 4; 24 | printf("%d == %d is %d \n", s, t, s == t); 25 | printf("%d > %d is %d \n", s, t, s > t); 26 | printf("%d < %d is %d \n", s, t, s < t); 27 | printf("%d != %d is %d \n", s, t, s != t); 28 | printf("%d >= %d is %d \n", s, t, s >= t); 29 | printf("%d <= %d is %d \n", s, t, s <= t); 30 | // Logical operator 31 | //RA2111027010043 32 | int i = 5, j = 5, k = 10, final; 33 | printf("i is equal to j or k greater than j is is %d \n", (i == j) && (k > j)); 34 | printf("i is equal to j or k less than j is %d \n", (i == j) || (k < j)); 35 | printf("i not equal to j or k less than j is %d \n", (i != j) || (k < j)); 36 | // Assignment operator 37 | //RA2111027010043 38 | int u = 21; 39 | int v ; 40 | v = u; 41 | printf(" = , Value of v = %d\n", v ); 42 | v += u; 43 | printf(" += , Value of v = %d\n", v ); 44 | v -= u; 45 | printf(" -= , Value of v = %d\n", v ); 46 | v *= u; 47 | printf(" *= , Value of v = %d\n", v ); 48 | v /= u; 49 | printf(" /= , Value of v = %d\n", v ); 50 | v = 200; 51 | v %= u; 52 | printf(" %= , Value of v= %d\n", v ); 53 | v <<= 2; 54 | printf(" <<= , Value of v = %d\n", v ); 55 | v >>= 2; 56 | printf(" >>= , Value of v = %d\n", v ); 57 | v &= 2; 58 | printf(" &= , Value of v = %d\n", v ); 59 | v ^= 2; 60 | printf(" ^= , Value of v = %d\n", v ); 61 | v |= 2; 62 | printf(" |= , Value of v = %d\n", v ); 63 | // Increment operator 64 | //RA2111027010043 65 | int e = 10; 66 | ++e; 67 | printf("Value of e: %d\n",e); 68 | // Decrement operator 69 | //RA2111027010043 70 | int f = 10; 71 | --f; 72 | printf("Value of f: %d\n",f); 73 | //Conditional operator 74 | //RA2111027010043 75 | int number=13; 76 | (number>14)? (printf("It is greater than number 14!")) : (printf("It is less than number 14!")); // conditional operator 77 | //Bitwise operator 78 | //RA2111027010043 79 | int a1 = 50; 80 | int b1 = 5; 81 | int result1 = 0; 82 | result1 = a1 & b1; // Binary AND Operator 83 | printf("\n\nBinary AND Operator of a1 and b1 is %d\n", result1 ); 84 | result1 = a1 ^ b1; // Binary XOR Operator 85 | printf("Binary XOR Operator of a1 and b1 is %d\n", result1 ); 86 | result1 = ~a1; // Binary Ones Complement Operator 87 | printf("Binary Ones Complement Operator of a1 is %d\n", result ); 88 | result1 = a1 << 2; // Binary Left Shift Operator 89 | printf("Binary Left Shift Operator of a1 is %d\n", result1 ); 90 | result1 = a1 >> 2; // Binary Right Shift Operator 91 | printf("Binary Right Shift Operator of a is %d\n", result1 ); 92 | //Special operator 93 | //RA2111027010043 94 | printf("Sizes of int, char and float...\n"); 95 | printf("int is: %d bytes\n", sizeof(int)); 96 | printf("char is: %d bytes\n", sizeof(char)); 97 | printf("float is: %d bytes\n", sizeof(float)); 98 | return 0; 99 | } --------------------------------------------------------------------------------