6.Bitwise operators:As the name suggest bitwise operators are the those operators that perform operations at level .These operation include : bitwise AND ,bitwise OR bitwise XOR and shift operators.

A.bitwise AND:like boolean AND (&&) bitwise (&) performs operation on bits instead of bytes ,char,integers etc.it oprends is 1 bit.it similar to the AND logical operators .

Ex. 10101010 & 01010101=00000000

Int a =10 ,b=20,c=0;

c=a&b;

B. bitwise OR:when we use the bitwise OR operator (|),the bit in the first operand is OR ed with the corresponding bit in the second oprand.

Ex. 10101010 & 01010101 =11111111

Int a=10,b=20,c=0;

c=a|b

C. bitwise XOR:The bitwise XOR operators (^) performs operation on individual bits of the operands .the first operand is XORed with the corresponding bit in the second operand.it operand 1 bits.

Ex. 10101010 ^ 01010101=11111111

Int a=10,b=20,c=0;

c=a^b

D.shift operators:C supports two type of bitwise operators the are shift -left(<<) and shift-right (>>).These operations are simple and are responsible for shifting bits either to left or to the right.

Ex.  of bitewise operators a complete programe…….

#include<stdio.h>

Int main(){

Int aa=27,b=39;

printf(“a & b=%d\n”,a&b);//3

printf(“a | b=%d\n”,a|b);//63

printf(“-a=%d\n”,-a);//-28

printf(“- b=%d\n”,-b);//-40

printf(“a ^ b=%d\n”,a^b);//60

printf(“a <<1=%d\n”,a<<1);//54

printf(“b>>1=%d\n”,b>>1);//19

}

Leave a comment

Design a site like this with WordPress.com
Get started