Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main(){
- int a = 3, b = 5, c = -3;
- printf("a = %d, b = %d, c = %d\n",a,b,c);
- printf("Bitwise AND operation of a and c gives %d \n", a & c);
- printf("Bitwise OR operation of b and c gives %d \n",b | c);
- printf("Bitwise EXOR operation of a and b gives %d \n",a ^ b);
- printf("3 Bitwise left shifts of c gives %d \n",c << 3);
- printf("4 Bitwise right shifts of a gives %d \n",a >> 4);
- printf("The result of the addition of pre-incremented c and pre-incremented a is %d \n",++c + --a);
- printf("The result of adding 1 to pre-decremented b is %d \n",--b + 1);
- printf("The result of a*b - c/b is %d \n",a *b - c / b);
- printf("Logical AND and OR of (a<b) and (b<c) is %d and ",(a < b) && (b < c));
- printf(" %d\n ",(a < b) || (b < c));
- printf("Using '+=10', the value of a has been changed to %d \n",a += 10);
- printf("Using '*=c', the value of b has been changed to %d \n",b *= c);
- printf("Using '/=b', the value of c has been changed to %d \n",c /= b);
- printf("Using unary minus, the b is now is %d\n", b = -b);
- }
- //Output
- //a = 3, b = 5, c = -3
- //Bitwise AND operation of a and c gives 1
- //Bitwise OR operation of b and c gives -3
- //Bitwise EXOR operation of a and b gives 6
- //Bitwise left shift of c gives -24
- //Bitwise right shift of a gives 0
- //The result of the addition of pre-incremented c and pre-incremented a is 0
- //The result of adding 1 to pre-decremented b is 5
- //The result of a*b - c/b is 8
- //Logical AND and OR reuslt is 0 1
- //Using '+=', the value of a has been changed to 12
- //Using '*=', the value of b has been changed to -8
- //Using '/=', the value of c has been changed to 0
- //Using unary minus, the b is now is 8
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement