Program that Implements Bitwise Operators.
#include<stdio.h>
int main(){
int a,b;
scanf("%d%d",&a,&b);
printf("Bitwise AND a & b is : %d",a&b);
printf("\nBitwise OR a | b is : %d",a|b);
printf("\nBitwise XOR a ^ b is : %d",a^b);
printf("\nBitwise NOT ~a is : %u",~a);
printf("\nShift Left <<, a<<1 is : %u",a<<1);
printf("\nShift Right >>, b>>1 is : %u",b>>1);
return 0;
}
Outputint main(){
int a,b;
scanf("%d%d",&a,&b);
printf("Bitwise AND a & b is : %d",a&b);
printf("\nBitwise OR a | b is : %d",a|b);
printf("\nBitwise XOR a ^ b is : %d",a^b);
printf("\nBitwise NOT ~a is : %u",~a);
printf("\nShift Left <<, a<<1 is : %u",a<<1);
printf("\nShift Right >>, b>>1 is : %u",b>>1);
return 0;
}
5 2
Bitwise AND a & b is : 0
Bitwise OR a | b is : 7
Bitwise XOR a ^ b is : 7
Bitwise NOT ~a is : 4294967290
Shift Left <<, a<<1 is : 10
Shift Right >>, b>>1 is : 1
Bitwise AND a & b is : 0
Bitwise OR a | b is : 7
Bitwise XOR a ^ b is : 7
Bitwise NOT ~a is : 4294967290
Shift Left <<, a<<1 is : 10
Shift Right >>, b>>1 is : 1