Notes in Hindi

What are Logical Operators in C Language in Hindi

/ BCA / Programming with C and CPP

Logical Operators in C Language in Hindi

What are Logical Operators in C Language in Hindi

C Language में Logical Operators का उपयोग decision लेने के लिए किया जाता है। जब हमें कोई condition check करनी होती है, जैसे कि "अगर Student के Marks 33 से ज्यादा हों और Attendance 75% से ज्यादा हो तभी पास करें", तब हम Logical Operators का उपयोग करते हैं।

Logical Operators का उपयोग conditions को जोड़ने (combine करने) या उनकी जाँच (evaluate करने) के लिए किया जाता है। ये operators result में true (1) या false (0) return करते हैं। इसका उपयोग decision making statements जैसे कि if, while, for में किया जाता है।

Logical Operators के प्रकार (Types of Logical Operators in Hindi)

  • Logical AND (&&) - जब दोनों conditions true हों तभी true return करता है।
  • Logical OR (||) - जब कोई एक condition भी true हो तो true return करता है।
  • Logical NOT (!) - condition को उल्टा (negate) करता है।

Types of Logical Operators in C with Truth Table in Hindi

नीचे तीनों logical operators के लिए Truth Table दी गई है जो यह बताती है कि अलग-अलग combinations पर ये operators क्या output देंगे।

Logical AND (&&) का Truth Table

Condition A Condition B A && B
0 0 0
0 1 0
1 0 0
1 1 1

Logical OR (||) का Truth Table

Condition A Condition B A || B
0 0 0
0 1 1
1 0 1
1 1 1

Logical NOT (!) का Truth Table

Condition A !A
0 1
1 0

Use of Logical Operators in decision making in Hindi

C Language में decision लेना बहुत जरूरी होता है, जैसे कि:

  • अगर Student पास है तो उसे Admit Card दो
  • अगर Employee का experience और salary दोनों criteria में आता है तो उसे Interview के लिए बुलाओ

इस प्रकार की स्थितियों में Logical Operators का उपयोग किया जाता है। उदाहरण के लिए:

#include <stdio.h> int main() { int marks = 80; int attendance = 90; if (marks >= 33 && attendance >= 75) { printf("Student Pass hai aur Admit Card mil sakta hai."); } else { printf("Student Fail hai ya Attendance kam hai."); } return 0; }

ऊपर के program में Logical AND (&&) operator ने दोनों conditions को check किया – marks और attendance – और फिर decision लिया।

Difference between Logical AND and Bitwise AND in Hindi

बहुत से students को confusion होता है कि Logical AND (&&) और Bitwise AND (&) में क्या अंतर है। चलिए इसे भी सरल भाषा में समझते हैं:

Property Logical AND (&&) Bitwise AND (&)
काम Conditions को Evaluate करता है Binary Bits पर काम करता है
Output 1 (true) या 0 (false) Bitwise Output देता है
Example (a > 10 && b < 20) 5 & 3 → 0101 & 0011 = 0001
Use Decision making में Bit manipulation में

अब इसका example भी देखें ताकि पूरी तरह clear हो जाए:

// Logical AND का उदाहरण #include <stdio.h> int main() { int a = 5, b = 10; if (a > 0 && b < 20) { printf("Dono conditions true hain."); } else { printf("Koi condition false hai."); } return 0; } // Bitwise AND का उदाहरण #include <stdio.h> int main() { int a = 5; // binary: 0101 int b = 3; // binary: 0011 int result = a & b; // result = 0001 = 1 printf("Bitwise AND ka result: %d", result); return 0; }

इस तरह से, Logical Operators का उपयोग program को intelligent और interactive बनाने के लिए किया जाता है। ये operators program के अंदर decision लेने के लिए बेहद जरूरी होते हैं। beginner को चाहिए कि पहले Logical AND (&&), Logical OR (||) और Logical NOT (!) को अच्छे से समझ लें और फिर real-life condition वाले examples पर प्रैक्टिस करें।

FAQs

Logical Operators ऐसे operators होते हैं जिनका उपयोग दो या अधिक conditions को check करने के लिए किया जाता है। ये true या false value return करते हैं और decision making statements जैसे if, while, for में use होते हैं।
Logical AND operator (&&) का उपयोग तब किया जाता है जब हमें दो conditions को एक साथ check करना हो और दोनों का true होना जरूरी हो। यदि दोनों conditions true हों तभी यह true देता है, अन्यथा false।
Logical AND (&&) conditions को check करता है और output में true या false देता है, जबकि Bitwise AND (&) binary level पर काम करता है और bits की तुलना करता है। Logical AND का उपयोग decision making में होता है जबकि Bitwise AND का उपयोग bitwise calculation में।
C Language में तीन प्रकार के Logical Operators होते हैं: Logical AND (&&), Logical OR (||), और Logical NOT (!)। ये सभी conditions को जोड़ने या negate करने के लिए use होते हैं।
Logical Operators का उपयोग मुख्य रूप से conditions को evaluate करने में होता है जैसे if-else, loops (for, while), validation checks, और decision-based programming logic में। ये program को intelligent और flexible बनाते हैं।

Please Give Us Feedback