TODAY JAVA SCHOOL

In java school, programming, design, computer general knowledge, web application, software, web services, social media, digital marketing, oops, concept of programming language, oops feature, console media, graphics medium, first programming, c, c ++ , Java, PHP, SQL, MySQL, HTML, HTML_5, J_query, JavaScript, Bootstrap, Framework, images with logos, examples, shared and explained.

https://www.amazon.in/b?node=26373545031&linkCode=ll2&tag=1234567801cdb-21&linkId=3b9882431b00409b44141e0344b35a15&language=en_IN&ref_=as_li_ss_tl

Breaking

Thursday, 7 May 2020

Bitwise Operator In C Language | Bitwise Operator In C Language In Hindi

Bitwise Operator In C Language

Bitwise operators are used for manipulating a data at the bit level, also called as bit level programming. Bit-level programming mainly consists of 0 and 1.

download image of bitwise operator in c
Fig: Bitwise Operator 


There are six type of bitwise operator in c language.

   1)   Left Shift Bitwise Operator (<<)
   2)   Right Shift Bitwise Operator (>>)
   3)   Inverse Bitwise Operator  (~)
   4)   Bitwise AND Operator (&)  
   5)   Bitwise OR Operator (|)
   6)   Exclusive Bitwise Operator (^)

1.Left Shift Bitwise Operator (<<)

The left shift operation will shift the 'n' number of bits to the left side.


Example:

a=13;
a<<2;

2.Right Shift Bitwise Operator(>>)

The right shift operation will shift the 'n' number of bits to the right side.


Example:

a=13;
a>>8;

3.Inverse Bitwise Operator(`)

The bitwise inverse is also called as one's complement operator since it always takes only one value or an operand. It is a unary operator.


Example:

a=7;
Binary digit=111
`a=000


4. Bitwise AND Operator (&)

Bitwise AND  operators, It is represented by a single ampersand sign (&). Two integer expressions are written on each side of the (&) operator.
The result of the bitwise AND operation is 1 if both the bits have the value as 1; otherwise, the result is always 0.


Example:

a                        b                               a&b
0                        0                               0
0                        1                               0
1                        0                               0
1                        1                               1

a=10101
b=01010
a&b=0000
   

5.Bitwise OR Operator (|)

It is represented by a single vertical bar sign (|). Two integer expressions are written on each side of the (|) operator.


Example:

a=0000 1101
a1=0001  1001


6. Bitwise Exclusion Operator (^)

It is represented by a symbol (^). Two integer expressions are written on each side of the (^) operator.


Example:

a=0000 1101
a1=0001  1001


 Program

#include<stdio.h>
#include<conio.h>
void main()
{
int   a=60;
int    b=13;
int c=0;
c=a&b;
printf(“Line1-value is c”);
c=a|b;
printf(“Line2-value is c”);
c=a^b;
printf(“Line3-value is c”);
c=`a;
printf(“Line4-value is c”);
c=a>>2;
printf(“Line5-value is c”);
c=a<<2;
printf(“Line6-value is c”);
getch();
}

Output:

Line1- value is c 12
Line2- value is c 61
Line3- value is c  49
Line4- value is c  61
Line5- value is c 240
Line6- value is c 15

No comments:

Post a Comment