Example :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | #include <stdio.h> #include <stdlib.h> int main() { unsigned int a= 30 ; unsigned int b=40; int c ; c= a & b ; printf("a and b = %d\n",c); c= a | b ; printf("a or b = %d\n",c); c=a^b; printf("a and b = %d\n",c); c=~a; printf("Compliment of a =%d\n",c); c= a << 2; printf("a shifted by 2 to the left = %d\n",c); c= a >> 2; printf("a shifted by 2 to the right = %d\n",c); return 0; } |
Output :
0 Comment to "Bitwise Operator in C "
Post a Comment