हिंदी माध्यम नोट्स
Categories: c++ language in hindi
C++ : Bitwise Operator (Part-2) in hindi , what are bit wise operators in c++ language in hinndi
what are bit wise operators in c++ language in hinndi , C++ : Bitwise Operator (Part-2) in hindi :-
इससे पहले article मे c++ : Bitwise operator ( पार्ट-1) मे bitwise OR , bitwise AND और bitwise XOR operation को discuss किया है | अब इस article मे , bitwise shift operator और not operator को discuss करेगे | जो की लॉजिकल operator से अलग होते है |
Logical OR Operator
इस operator से किसी दो number के bit pattern मे OR operation को perform किया जाता है | गर दोनो bits मे कोई एक बिट “1” होता है तब इस expression का आउटपुट भी ‘1’ होगा |
Logical AND Operator
इस operator से किसी दो number के bit pattern मे AND operation को perform किया जाता है | अगर दोनो bits “1 होता है तब इस expression का आउटपुट भी ‘1’ होगा |
Logical XOR Operator
इस operator से किसी दो number के bit pattern मे xor operation को perform किया जाता है | अगर दोनो bits equal होती है तब ही इस expression का आउटपुट भी ‘1’ होगा |
Bitwise Shift operator
जिस प्रकार bitwise OR , bitwise AND और bitwise XOR से basic लॉजिकल operation को perform किया जाता है | लेकीन Shifting operator से केवल किसी number के बिट पैटर्न मे shifting operation को परफोर्म किया जाता है | ये दो प्रकार के होते है :
1.Bitwise Right Shifting
जब किसी bits pattern right shifting operation perfrom किया जाता है | तब इस Bitwise Right operator का use किया जाता है | इसका syntax ” >>” है | इसका genral statement format होता है |
operand >> n;
यह पर
operand : ये operand का नाम होता है जिसमे shifting operation को perform किया जाता है |
n : ये number को बिट जिसे shift करना होता है |
जब किसी बिट पैटर्न मे right shifting operation को perform किया जाता है | तब n bits right side shift होती है और अगर value unsigned होती है तब vacant space पर ‘0’ insert होता है | और value signed होती है तब vacant space पर signed bit insert हो जाती है | और इसका decimal number store हो जाता है |
इसका उदाहरण होता है :-
#include<iostream.h>
#include<conio.h>
void main()
{
int a ;
cout<<“Enter Value :”<<endl;
cin>>a;
a=a>>3;
cout<<” After Shifting operation : “<<a<,endl;
getch();
}
इस उदाहरण मे variable को declare किया जाता है | फिर यूजर द्वारा value को input करा लेते है और इसे variable ‘a’ मे assign करा देते है |
और a=a>>3 expression का मतलब है की variable ‘a’ की value के बिट पैटर्न मे बिट मे right side मे shifting होगी | और shift की जनि वाली बिट की सख्या ‘3’ होगी और vacant place पर ‘0’ insert हो जाती है |
BIT Pattern of value 67 : 1000011
after shifting Operation: 0001000 ( Equal to decimal number : 16)
इसका आउटपुट होगा
Enter Value : 67
After Shifting operation : 16
2. Bitwise Left Shifting
जब किसी bits pattern left shifting operation perfrom किया जाता है | तब इस Bitwise Left operator का use किया जाता है | इसका syntax “<<” है | इसका genral statement format होता है |
operand << n;
यह पर
operand : ये variable का नाम होता है jis par shifting operation को perform किया जाता है |
n : ये bit की सख्या है जिसे shift करना होता है |
जब किसी बिट पैटर्न मे left shifting operation को perform किया जाता है | तब n bits left side shift होती है तब bit pattern की left most bit eliminate हो जाती है | right side जो भी place vacant हो जाते है उस place पर ‘0’ store हो जाता है |
इसका उदाहरण होता है :-
#include<iostream.h>
#include<conio.h>
void main()
{
int a;
cout<<“Enter Value :”<<endl;
cin>>a;
a=a<<3;
cout<<” After Shifting operation : “<<a<,endl;
getch();
}
इस उदाहरण मे variable को declare किया जाता है | फिर यूजर द्वारा value को input करा लेते है और इसे variable ‘a’ मे assign करा देते है |
और a=a<<3 expression का मतलब है की variable ‘a’ की value के बिट पैटर्न मे बिट मे left side मे shifting होगी | और shift की जानी वाली बिट की सख्या ‘3’ होगी और vacant place पर ‘0’ insert हो जाती है |
BIT Pattern of value 67 : 1000011
after shifting Operation: 0011000 ( Equal to decimal number : 24)
इसका आउटपुट होगा
Enter Value : 67
After Shifting operation : 24
3. Bitwise Not operator
इस operator का use , किसी bit pattern के inverted form को calculate करने के लिए किया जाता है | इसका syntax “~” होता है | इसका genral statement format होता है |
~ operand;
यहा पर
~ : ये bitwise not operator का keyword होता है |
operand : ये variable का नाम है जिस पर not operation perform किया जाता है |
इसका truth tabel होता है |
अगर input a = 1 than output 0 होता है |
अगर input a = 0 than output 1 होता है |
#include<iostream.h>
#include<conio.h>
void main()
{
int a;
cout<<“Enter First Value :”<<endl;
cin>>a;
a=~a;
cout<<“After NOT Operation : “<<a<<endl;
getch();
}
इस उदाहरण मे variable को declare किया जाता है | फिर यूजर द्वारा value को input करा लेते है और इसे variable ‘a’ मे assign करा देते है |
और a=~a; expression का मतलब है की variable ‘a’ की value के बिट पैटर्न मे बिट मे invert कर दिया जाता है |
BIT Pattern of value 67 : 1000011
after NOT Operation : 0111100 ( Equal to decimal number : 60)
इसका आउटपुट होगा
Enter Value : 67
After Shifting operation : 60
जब किसी bitwise operator use किया जाता है तब कुछ बातो का ध्यान रखना चाहिए | ये निन्म है :
1.Shifting operator ( Both Right और left ) का use negative value के साथ नहीं किया जा सकता है |
2.Bitwise XOR operator को इंटरव्यू मे सबसे ज्यादा पूछा जाता है |
3.Bitwise operator को logical operator के स्थान पर use नहीं किया जा सकता है|
4.left और right shift operator का use , किसी value को ‘2’ से divide और multiplication करने के लिए use किया जाता है |
5.bitwise AND operator का use even और odd की condition को check करने के लिए किये जाता है |
6.Bitwise Not operator का use बहुत ध्यान पूर्वक करना चाहिए |
इस article मे bitwise operator को discuss किया है | आगे आने वाले article मे Bitwise Operator : Example मे उदाहरनो को discuss करेगे |
Recent Posts
मालकाना का युद्ध malkhana ka yudh kab hua tha in hindi
malkhana ka yudh kab hua tha in hindi मालकाना का युद्ध ? मालकाना के युद्ध…
4 weeks ago
कान्हड़देव तथा अलाउद्दीन खिलजी के संबंधों पर प्रकाश डालिए
राणा रतन सिंह चित्तौड़ ( 1302 ई. - 1303 ) राजस्थान के इतिहास में गुहिलवंशी…
4 weeks ago
हम्मीर देव चौहान का इतिहास क्या है ? hammir dev chauhan history in hindi explained
hammir dev chauhan history in hindi explained हम्मीर देव चौहान का इतिहास क्या है ?…
4 weeks ago
तराइन का प्रथम युद्ध कब और किसके बीच हुआ द्वितीय युद्ध Tarain battle in hindi first and second
Tarain battle in hindi first and second तराइन का प्रथम युद्ध कब और किसके बीच…
4 weeks ago
चौहानों की उत्पत्ति कैसे हुई थी ? chahamana dynasty ki utpatti kahan se hui in hindi
chahamana dynasty ki utpatti kahan se hui in hindi चौहानों की उत्पत्ति कैसे हुई थी…
1 month ago
भारत पर पहला तुर्क आक्रमण किसने किया कब हुआ first turk invaders who attacked india in hindi
first turk invaders who attacked india in hindi भारत पर पहला तुर्क आक्रमण किसने किया…
1 month ago