- Program :
#include <stdio.h>
#include<conio.h>
void main()
{
int a,b,num=252,i;
clrscr();
printf("\n----------------BITWISE OPERATORS----------------");
printf("\nEnter any two values:");
scanf("%d%d",&a,&b);
printf("\n----------------BITWISE OPERATOR(&)----------------");
printf("\nBitwise AND is : %d",a&b);
printf("\n----------------BITWISE OPERATOR(|)----------------");
printf("\nBitwise OR is : %d",a|b);
printf("\n----------------BITWISE OPERATOR(^)----------------");
printf("\nBitwise XOR is : %d", a^b);
printf("\n----------------BITWISE OPERATOR(~)----------------");
printf("\nBitwise complement operator is : %d",~a);
printf("\nBitwise complement operator is : %d",~-b);
printf("\n----------------BITWISE OPERATOR(>>)----------------");
for (i=0; i<=2; ++i)
printf("\nRight shift %d is : %d",i,m>>i);
printf("\n----------------BITWISE OPERATOR(>>)----------------");
for (i=0; i<=2; ++i)
printf("\nLeft shift %d is : %d",i,m<<i);
getch();
}
- Output :
No comments:
Post a Comment