बिट वाइज ऑपरेटर : लॉजिकल ऑपरेटर हिंदी में c कंप्यूटर भाषा में , Bitwise Operator : Logical Operator in hindi :-
C language का most unique feature है bit level programming |Bit level
programming एक एसी प्रोग्रामिंग होती जिसमे किसी word के
individual bits पर operation किया जाता है |Bit
level programming से कई कैलकुलेशन easy और
faster हो जाती है |
programming एक एसी प्रोग्रामिंग होती जिसमे किसी word के
individual bits पर operation किया जाता है |Bit
level programming से कई कैलकुलेशन easy और
faster हो जाती है |
इसके लिए तीन प्रकार के operator होते
है :-
है :-
1. Bitwise logical operator
2. Bitwise Shift operator
3. one’s compliment operator
सभी operator
,integer के बिट value
पर काम करते है |
,integer के बिट value
पर काम करते है |
Bitwise logical operator
Bitwise logical operator तीन प्रकार के होती है |
1. Bitwise And operator
2. Bitwise OR operator
3. Bitwise Not operator
ये bitwise
operator होते है |अतः ये दो integer
value के bits
पर कार्य करता है |ये leftsidebits से
start होते है सभी individual
bits के आउटपुट हो store करता
है |जैसे
operator होते है |अतः ये दो integer
value के bits
पर कार्य करता है |ये leftsidebits से
start होते है सभी individual
bits के आउटपुट हो store करता
है |जैसे
दो input
है 1011
और 0001
तब नीचे दिए table मे
आउटपुट सेव है :
है 1011
और 0001
तब नीचे दिए table मे
आउटपुट सेव है :
operand1(o1)
|
Operand
2 (o2) |
O1&o2
|
O1||o2
|
1
|
0
|
0
|
1
|
1
|
0
|
0
|
1
|
0
|
0
|
0
|
1
|
1
|
1
|
1
|
0
|
1.Bitwise And operator
इस operator का syntax ‘&’ है | ये ‘&’ दोनों तरह से integer
operands से क्लोज होता है |and operation का आउटपुट ‘1’ होगा जब दोनों तरह के input ‘1’ होगा या ‘0’ होगा tab कोई भी एक input ‘0’ या दोनों ही ‘0’ होगा |
operands से क्लोज होता है |and operation का आउटपुट ‘1’ होगा जब दोनों तरह के input ‘1’ होगा या ‘0’ होगा tab कोई भी एक input ‘0’ या दोनों ही ‘0’ होगा |
जैसे दो integer 13 और 23 है जिसका बिट value है |
13 : 00001101
23 : 00011001
इन बिट का आउटपुट होगा :-
operand
1 |
Operand
2 |
And
operation output |
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
1
|
0
|
1
|
1
|
1
|
1
|
0
|
0
|
0
|
0
|
0
|
1
|
1
|
1
|
आउटपुट का integer ‘9’ है |
bitwise and operator का use किसी particular बिट को‘0’ और‘1’ test करने के लिए किया जाता है |जैसे नीचे दिए गये
प्रोग्राम मे , fourth बिट ‘1’ की condition को check किया जाता है |
प्रोग्राम मे , fourth बिट ‘1’ की condition को check किया जाता है |
#include<stdio.h>
#include<conio.h>
#define T 8
void main()
{
{
int a;
printf(“Enter value
for checking”);
for checking”);
if(a&t)
{
printf(“fourth bit
of value is ‘1’.”);
of value is ‘1’.”);
}
else
{
printf(“fourth bit
of value is not ‘1’.”);
of value is not ‘1’.”);
}
getch();
}
इस प्रकार से bitwise and operator के साथ even-odd के
प्रोग्राम को use कर सकते है |
प्रोग्राम को use कर सकते है |
#include<stdio.h>
#include<conio.h>
void main()
{
{
int a;
int t=1;
printf(“Enter value
for checking”);
for checking”);
scanf(“%d”,&a);
while(a!=-1)
{
if(a&t)
{
printf(“Number is
odd”);
odd”);
}
else
{
printf(“Number is
even “);
even “);
}
}
getch();
}
2.Bitwise OR
Operator
Operator
इस operator का syntax ‘|’ है |ये ‘|’ दोनों तरह से integer
operands से क्लोज होता है |OR operation का आउटपुट ‘0’ होगा जब दोनों तरह के input ‘0’ होगा |
operands से क्लोज होता है |OR operation का आउटपुट ‘0’ होगा जब दोनों तरह के input ‘0’ होगा |
या ‘1`’ होगा कोई भी एक input ‘1’ या दोनों
ही ‘1’ होगा |
ही ‘1’ होगा |
जैसे दो integer 13 और 23 है जिसका बिट value है |
13 : 00001101
23 : 00011001
इन बिट का आउटपुट होगा :-
operand
1 |
Operand
2 |
And
operation output |
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
1
|
1
|
1
|
1
|
1
|
1
|
0
|
1
|
0
|
0
|
0
|
1
|
1
|
1
|
आउटपुट का integer ’28’ है |
bitwise and operator का use किसी particular बिट को‘ ‘1’ set करने के
लिए किया जाता है |जैसे पहले variable ‘a’ की bit value मे fourth बिट ‘1’ set होगा फिर , fourth बिट ‘1’ की condition को check किया जाता है |
लिए किया जाता है |जैसे पहले variable ‘a’ की bit value मे fourth बिट ‘1’ set होगा फिर , fourth बिट ‘1’ की condition को check किया जाता है |
#include<stdio.h>
#include<conio.h>
#define T 8
void main()
{
{
int a;
printf(“Enter value
for checking”);
for checking”);
scanf(“%d”,&a);
a=a|t;
if(a&t)
{
printf(“fourth bit
of value set 1 .”);
of value set 1 .”);
}
else
{
printf(“fourth bit
of value did not set 1 .”);
of value did not set 1 .”);
}
getch();
}
XOR Operation
इस operator का syntax ‘^’ है |ये ‘^’ दोनों तरह से integer
operands से क्लोज होता है |
operands से क्लोज होता है |
XOR operation का आउटपुट ‘0’ होगा जब दोनों तरह के input ‘0’ या ‘1’ होगा |
या ‘1`’ होगा अगर कोई भी एक input ‘1’ होगा |
जैसे दो integer 13 और 23 है जिसका बिट value है |
13 : 00001101
23 : 00011001
इन बिट का आउटपुट होगा :-
operand
1 |
Operand
2 |
xor
operation output |
0
|
0
|
1
|
0
|
0
|
1
|
0
|
0
|
1
|
0
|
1
|
0
|
1
|
1
|
1
|
1
|
0
|
0
|
0
|
0
|
0
|
1
|
1
|
1
|
उदहारण के लिए :
#include<conio.h>
#include<stdio.h>
void main()
{
int a,b;
int a,b;
printf(“Enter data “);
scnaf(“%d %d”,&a,&b);
int c;
c=a^b;
printf(“XOR of a ,b is %d”,c);
getch();
}
आउटपुट होगा :
Enter data 12 33
XOR of a ,b is 223