Bitwise operators in c hindi
C लैंग्वेज में बिटवाइज़ ऑपरेटर स्टोरेज लोकेशन में एक इन्टिजर टाइप के भीतर अलग-अलग बिट्स को मेन्युप्लेट करता हैं। बिटवाइज़ ऑपरेटर का उपयोग आमतौर पर लौ लेवल कंप्यूटर प्रोग्रामिंग में होता है, जैसे कि लौ लेवल कंप्यूटर प्रोग्रामिंग सिस्टम प्रोग्रामिंग, एम्बेडेड सिस्टम, कंप्यूटर हार्डवेयर और अन्य एप्लीकेशन में होता है।

Types of Bitwise Operators in C Language.
• AND (&)
• OR (|)
• XOR (^)
• NOT (~)
• Left Shift (<<)
• Right Shift (>>)
C Language Bitwise AND (&) Operator.
सी लैंग्वेज में AND ऑपरेटर अपने ऑपरेंड के प्रत्येक बिट की तुलना करता है। एंड ऑपरेटर में यदि दोनों बिट 1 पर हैं, तो रिजल्ट 1 है, अन्यथा, रिजल्ट 0 होगा है।
AND Operator Example in C Language.
#include <stdio.h>
int main() {
int p = 7;
int q = 9;
int output = p & q;
printf(“\n p & q and operator is – %d\n”, output);
return 0;
}
Bitwise OR (|) operator in C.
OR ऑपरेटर अपने ऑपरेंड के प्रत्येक बिट की तुलना करता है। यदि कम से कम एक बिट 1 है, तो परिणाम 1 है, अन्यथा, परिणाम 0 है।
Bitwise OR example.
#include <stdio.h>
int main() {
int p = 9;
int q = 7;
int output = p | q;
printf(“\n the or operator p | q = %d”, output);
return 0;
}
Bitwise XOR (^) in C.
सी लैंग्वेज में बिटवाइज़ XOR ऑपरेटर अपने ऑपरेंड के प्रत्येक बिट की तुलना करता है। यदि बिट अलग-अलग एलिमेंट हैं, तो रिजल्ट 1 है, अन्यथा, रिजल्ट 0 है।
Example of Bitwise XOR (^).
#include <stdio.h>
int main() {
int p = 4;
int q = 6;
int output = p ^ q;
printf(“\n p ^ q xor values is – %d”, output);
return 0;
}
Bitwise NOT (~) in C.
सी लैंग्वेज बिटवाइज़ NOT ऑपरेटर यह अपने ऑपरेंड के सभी बिट्स वैल्यू को उलट देता है।
Example of Bitwise NOT in C.
#include <stdio.h>
int main() {
int p = 7;
int output = ~p;
printf(“\n the bitwise not ~p = %d”, output);
return 0;
}
Left Shift (<<) Operator in C.
सी प्रोग्राम में लेफ्ट शिफ्ट बिटवाइज़ ऑपरेटर बिट्स को स्पेसिफिक लोकेशन पोजीशन से बाईं ओर मूव करता है। इसके बाद शिफ्ट किए गए स्टोरेज बिट्स लोकेशन को इग्नोर करता है, और दाईं ओर से शून्य बिट्स को मूव करता है।
Left shift bitwise operator example in C.
#include <stdio.h>
int main() {
int p = 7;
int output = p << 1;
printf(“the left shit operator is p = << 1 = %d”, output);
return 0;
}
Right Shift (>>) Operator in C.
सी लैंग्वेज में राइट शिफ्ट ऑपरेटर बिट्स को स्पेसिफिक लोकेशन में दाईं ओर शिफ्ट करता है। अनसाइंड डाटा टाइप्स में, अंत से शिफ्ट किए गए डाटा बिट्स को इग्नोर कर दिया जाता है, और शून्य बिट्स को बाईं ओर से शिफ्ट किया जाता है। अनसाइंड डाटा टाइप के लिए, साइन बिट का उपयोग सबसे बाईं ओर के बिट्स (अर्थमेटिक मूव) को भरने के लिए किया जाता है।
Right Shift Operator Example.
#include <stdio.h>
int main() {
int p = 7;
int output = p >> 1;
printf(“\n right shit operator p >> 1 location is – %d\n”, output);
return 0;
}
Bitwise Operations in C Program.
Setting a Bit in C Program Example.
किसी विशिष्ट बिट लोकेशन को 1 पर सेट करने के लिए, आप बिटवाइज़ OR ऑपरेटर का उपयोग मास्क के साथ करें, जिसमें की वांछित बिट 1 लोकेशन पर मूव हो जाता है।
#include <stdio.h>
int main() {
int p = 9;
int bit_loc_set = 1;
int output = p | (1 << bit_loc_set);
printf(“\n the output after setting the bit location – %d – %d”, bit_loc_set, output);
return 0;
}
Clearing a bit in C example.
सी प्रोग्राम में किसी विशिष्ट बिट को 0 पर क्लियर करने के लिए, आप बिटवाइज़ AND ऑपरेटर का उपयोग मास्क के साथ करें, जिसमें डिजायर बिट 0 लोकेशन पर स्टोर हो।
#include <stdio.h>
int main() {
int p = 7;
int bit_loc_clear = 3;
int output = p & ~(1 << bit_loc_clear);
printf(“\n the output after the clearing bit – %d %d\n”, bit_loc_clear, output);
return 0;
}
Bit toggling in C example.
सी प्रोग्राम में किसी पर्टिकुलर बिट को टॉगल करने के लिए (इसे उलट दें), बिटवाइज़ XOR ऑपरेटर का उपयोग मास्क के साथ किया जाता है. जिसमें डिजायर बिट लोकेशन 1 पर स्टोर हो।
#include <stdio.h>
int main() {
int p = 7;
int bit_loc_toggle = 0;
int output = p ^ (1 << bit_loc_toggle);
printf(“\n the output after toggling bit is – %d %d\n”, bit_loc_toggle, output);
return 0;
}
Example Checking a Bit in c.
सी प्रोग्राम में यह जाँचने के लिए कि क्या कोई विशिष्ट बिट सेट है, तो बिटवाइज़ AND ऑपरेटर का उपयोग मास्क के साथ किया जाता है, जिसमें डिजायर बिट 1 लोकेशन पर सेट हो।
#include <stdio.h>
int main() {
int p = 7;
int bit_loc_check = 5;
int output = p & (1 << bit_loc_check);
if (output) {
printf(“\n the checking Bit is set to – %d”,bit_loc_check);
} else {
printf(“\n the checking Bit is not set to – %d”,bit_loc_check);
}
return 0;
}