From the following code of lines you can understood the Use of Bitwise Logical Operators in C language :
Code:
#include<stdio.h>
main()
{
char d1,d2,d3;
printf("enter value for d1 and d2");
scanf("%c,%c",&d1,&d2);
d3 = d1 & d2;
printf("\n d1 & d2 = %c",d3);
d3 = d1 | d2;
printf("\n d1 | d2 = %c",d3);
d3 = d1 ^ d2;
printf("\n i.e. d1 ^ d2 = %c",d3);
d3 = ~d1;
printf("\n compliment of d1 = %c",d3);
d3 = d1<<2;
printf("\n left shift by 2 bits d1 << 2 = %c",d3);
d3 = d1>>2;
printf("\n right shift by 2 bits d1 >> 2 = %c",d3);
}
Bookmarks