हिंदी माध्यम नोट्स
Categories: c++ language in hindi
C++ : Bitwise Operator ( Part-1 ) in hindi , what is Bitwise Operators in c++ language
what is Bitwise Operators in c++ language , C++ : Bitwise Operator ( Part-1 ) in hindi :-
इससे पहले एक article मे c++ मे उपस्थित केवल arithmatic operator or relation operator or logical operator को discuss किया है | अब इस article मे bitwise operator को discuss करेगे |
c++ मे operators main bitwise operator का मुख्य भूमिका है :-
arithmetic operator
इस category मे पांच arithmatic operators है जिसमे addition(+),subtraction(-) , multiplication(*) , division(/), और modulas(%) है | इस सभी operator को basic arithmatic operation मे use किया जाता है | इन सभी को हम पहले अच्छी तरह से discuss कर चुके है |
2. Relation operator
जब किसी प्रोग्राम मे दो या दो से अधिक संख्याओं में तुलना करने के काम में लिया जाता है तब इस operator को उपयोग किया जाता है | इस श्रेणी मे पांच Relation operator (सम्बन्ध ऑपरेटर) है | जब किसी expression मे Relation operator को उपयोग किया जाता है तब इसे Relation expression कहते है | सभी Relation expression की value Boolean होती है | अथात इसकी true और false value होती है | इसमें larger than (>) , smaller than(<) , larger and equal than (>=) और smaller and equal than (<=) होता है | Equal than (==)operator भी Relation operator होता है |
3. Logical Operator
ये operator का दो या दो से अधिक relation expressions को जोड़ने के लिए किया जाता है | इसमें logical and operator (&&) , logical Or operator (||) ओए logical or होता है |
Bitwise operator
Bitwise operator का use, bit level operation के लिए किया जाता है | इसके लिए bit operand होते है इसका मतलब है की bitwise operator का use , bits पर होता है | ये operator operand को bits मे convert कर देता है | उसके बाद operation perform होता है |bits पर Mathematical operator को perform करने से speed बढ़ जाती है |
C++ मे bitwise operator को पांच भागो मे divind किया गया है :-
1. Bitwise OR
जब किसी दो bits pattern के बीच OR operation perform किया जाता है | तब इस Bitwise OR का use किया जाता है | इसका syntax “|” है | अगर दोनो bits मे कोई एक बिट “true” होता है तब इस expression का आउटपुट भी ‘1’ होगा |
इस operation मे सबसे पहले number को बिट पैटर्न मे convert कर दिया जाता है | फिर उस पर bitwise OR operation परफोर्म किया जाता है |
इसका truth table होता है |
अगर bit a = 1 or int b= 1 than output 1 होता है |
अगर bit a = 1 or int b= 0 than output 1 होता है |
अगर bit a = 0 or int b= 1 than output 1 होता है |
अगर bit a = 0 or int b= 0 than output 0 होता है |
इसका उदाहरण होता है :-
#include<iostream.h>
#include<conio.h>
void main()
{
int a,b,d;
cout<<“Enter First Value :”<<endl;
cin>>a;
cout<<“Enter Second Value :”<<endl;
cin>>b;
d=a|b;
cout<<“OR Operation Output:”<<d<,endl;
getch();
}
इस उदाहरण मे दो variable को declare किया जाता है | जिसको variable ‘a’ और ‘b’ मे assign कर दिया जाता है |
और d=a|b expression के आउटपुट को variable d मे assign कर देते है | इस variable का type integer है |
BIT Pattern of first value 12 : 01100
BIT Pattern of first value 23 : 10111
after OR Operation : 11111 ( Equal to decimal number : 31)
इसका आउटपुट होगा
Enter First Value : 12
Enter Second Value : 23
OR Operation Output: 31
2. Bitwise AND
जब किसी दो bits pattern के बीच AND operation perfrom किया जाता है | तब इस Bitwise AND का use किया जाता है | इसका syntax “&” है | अगर दोनो bits “true” होता है तब इस expression का आउटपुट भी ‘1’ होगा |
इस operation मे सबसे पहले number को बिट पैटर्न मे convert कर दिया जाता है | फिर उस पर bitwise and operation परफोर्म किया जाता है |
इसका truth table होता है |
अगर bit a = 1 or int b= 1 than output 1 होता है |
अगर bit a = 1 or int b= 0 than output 0 होता है |
अगर bit a = 0 or int b= 1 than output होता है |
अगर bit a = 0 or int b= 0 than output 0 होता है |
इसका उदाहरण होता है :-
#include<iostream.h>
#include<conio.h>
void main()
{
int a,b,d;
cout<<“Enter First Value :”<<endl;
cin>>a;
cout<<“Enter Second Value :”<<endl;
cin>>b;
d=a&b;
cout<<“AND Operation Output:”<<d<,endl;
getch();
}
इस उदाहरण मे दो variable को declare किया जाता है | जिसको variable ‘a’ और ‘b’ मे assign कर दिया जाता है |
और d=a|b expression के आउटपुट को variable d मे assign कर देते है | इस variable का type integer है |
BIT Pattern of first value 34 : 100010
BIT Pattern of first value 54 : 110110
after AND Operation : 100010 ( Equal to decimal number : 34)
इसका आउटपुट होगा
Enter First Value : 34
Enter Second Value : 54
AND Operation Output: 34
3. Bitwise Xor
जब किसी दो bits pattern के बीच XOR operation perfrom किया जाता है | तब इस Bitwise XOR का use किया जाता है | इसका syntax “^” है | अगर दोनो bits सामान होती है तब ही इस expression का आउटपुट भी ‘1’ होगा |
इस operation मे सबसे पहले number को बिट पैटर्न मे convert कर दिया जाता है | फिर उस पर bitwise XOR operation परफोर्म किया जाता है | इस operator का use कई सारे operation मे किया जाता है |
इसका truth table होता है |
अगर input a = 1 or int b= 1 than output 1 होता है |
अगर input a = 1 or int b= 0 than output 0 होता है |
अगर input a = 0 or int b= 1 than output 0 होता है |
अगर input a = 0 or int b= 0 than output 1 होता है |
इसका उदाहरण होता है :-
#include<iostream.h>
#include<conio.h>
void main()
{
int a,b,d;
cout<<“Enter First Value :”<<endl;
cin>>a;
cout<<“Enter Second Value :”<<endl;
cin>>b;
d=a&b;
cout<<“AND Operation Output:”<<d<,endl;
getch();
}
इस उदाहरण मे दो variable को declare किया जाता है | जिसको variable ‘a’ और ‘b’ मे assign कर दिया जाता है |
और d=a^b expression के आउटपुट को variable d मे assign कर देते है | इस variable का type integer है |
BIT Pattern of first value 67 : 1000011
BIT Pattern of first value 98 : 1100010
after XOR Operation : 1011110( Equal to decimal number : 94)
इसका आउटपुट होगा
Enter First Value : 67
Enter Second Value : 98
AND Operation Output: 94
इस article मे , उन bit-wise operator को discuss किया है जो की लॉजिकल operator के सामान होते है उनमे केवल एक अंतर होता है की लॉजिकल operator Relation expression के output पर apply होता है और bitwise operator bits पर अप्लाई होता है | इसके आगे के article मे shift operator को discuss करेगे |
Recent Posts
सती रासो किसकी रचना है , sati raso ke rachnakar kaun hai in hindi , सती रासो के लेखक कौन है
सती रासो के लेखक कौन है सती रासो किसकी रचना है , sati raso ke…
21 hours ago
मारवाड़ रा परगना री विगत किसकी रचना है , marwar ra pargana ri vigat ke lekhak kaun the
marwar ra pargana ri vigat ke lekhak kaun the मारवाड़ रा परगना री विगत किसकी…
21 hours ago
राजस्थान के इतिहास के पुरातात्विक स्रोतों की विवेचना कीजिए sources of rajasthan history in hindi
sources of rajasthan history in hindi राजस्थान के इतिहास के पुरातात्विक स्रोतों की विवेचना कीजिए…
3 days ago
गुर्जरात्रा प्रदेश राजस्थान कौनसा है , किसे कहते है ? gurjaratra pradesh in rajasthan in hindi
gurjaratra pradesh in rajasthan in hindi गुर्जरात्रा प्रदेश राजस्थान कौनसा है , किसे कहते है…
3 days ago
Weston Standard Cell in hindi वेस्टन मानक सेल क्या है इससे सेल विभव (वि.वा.बल) का मापन
वेस्टन मानक सेल क्या है इससे सेल विभव (वि.वा.बल) का मापन Weston Standard Cell in…
3 months ago
polity notes pdf in hindi for upsc prelims and mains exam , SSC , RAS political science hindi medium handwritten
get all types and chapters polity notes pdf in hindi for upsc , SSC ,…
3 months ago