Relational Operators in C Language (C लैंग्वेज में रिलेशनल ऑपरेटर्स) Introduction to Relational Operators (रिलेशनल ऑपरेटर्स का परिचय)

A relational operator is used to compare two operands and check the relationship between them. It returns 1 (true) if the specified condition is satisfied and 0 (false) if the condition is not satisfied.

रिलेशनल ऑपरेटर का उपयोग दो ऑपरेंड्स के बीच तुलना करने तथा उनके मध्य संबंध की जाँच करने के लिए किया जाता है। यदि दी गई कंडीशन सत्य होती है, तो यह 1 (True) तथा असत्य होने पर 0 (False) परिणाम देता है।

Relational operators are binary operators because they compare two operands.

रिलेशनल ऑपरेटर्स बाइनरी ऑपरेटर्स होते हैं क्योंकि ये दो ऑपरेंड्स की तुलना करते हैं।

Let A = 10 and B = 5.

माना कि A = 10 तथा B = 5 हैं।

Types of Relational Operators in C (C में रिलेशनल ऑपरेटर्स के प्रकार)

The following table represents relational operators, their descriptions, and examples.

निम्न तालिका में रिलेशनल ऑपरेटर्स, उनके संक्षिप्त विवरण तथा उदाहरण दर्शाए गए हैं।

OperatorDescription (विवरण)Example
==Equal to (बराबर)(A == B) → False (0)
!=Not equal to (बराबर नहीं)(A != B) → True (1)
>Greater than (से बड़ा)(A > B) → True (1)
<Less than (से छोटा)(A < B) → False (0)
>=Greater than or equal to (से बड़ा या बराबर)(A >= B) → True (1)
<=Less than or equal to (से छोटा या बराबर)(A <= B) → False (0)

1. Equal to Operator (==) (बराबर ऑपरेटर)

The equal to operator == checks whether two operands have equal values. It returns 1 if both values are equal; otherwise, it returns 0.

Equal to ऑपरेटर == यह जाँचता है कि दो ऑपरेंड्स के मान समान हैं या नहीं। यदि दोनों मान समान होते हैं, तो यह 1 अन्यथा 0 देता है।

Example:

int A = 10, B = 5;
printf("%d", A == B);

Output:

0

2. Not Equal to Operator (!=) (बराबर नहीं ऑपरेटर)

The not equal to operator != checks whether two operands have different values. It returns 1 if the values are different; otherwise, it returns 0.

Not Equal to ऑपरेटर != यह जाँचता है कि दो ऑपरेंड्स के मान अलग-अलग हैं या नहीं। यदि दोनों मान अलग होते हैं, तो यह 1 अन्यथा 0 देता है।

Example:

int A = 10, B = 5;
printf("%d", A != B);

Output:

1

3. Greater than Operator (>) (से बड़ा ऑपरेटर)

The greater than operator > checks whether the first operand is greater than the second operand.

Greater than ऑपरेटर > यह जाँचता है कि पहला ऑपरेंड दूसरे ऑपरेंड से बड़ा है या नहीं।

Example:

int A = 10, B = 5;
printf("%d", A > B);

Output:

1

4. Less than Operator (<) (से छोटा ऑपरेटर)

The less than operator < checks whether the first operand is smaller than the second operand.

Less than ऑपरेटर < यह जाँचता है कि पहला ऑपरेंड दूसरे ऑपरेंड से छोटा है या नहीं।

Example:

int A = 10, B = 5;
printf("%d", A < B);

Output:

0

5. Greater than or Equal to Operator (>=) (से बड़ा या बराबर ऑपरेटर)

The greater than or equal to operator >= checks whether the first operand is greater than or equal to the second operand.

Greater than or Equal to ऑपरेटर >= यह जाँचता है कि पहला ऑपरेंड दूसरे ऑपरेंड से बड़ा है या उसके बराबर है।

Example:

int A = 10, B = 5;
printf("%d", A >= B);

Output:

1

6. Less than or Equal to Operator (<=) (से छोटा या बराबर ऑपरेटर)

The less than or equal to operator <= checks whether the first operand is smaller than or equal to the second operand.

Less than or Equal to ऑपरेटर <= यह जाँचता है कि पहला ऑपरेंड दूसरे ऑपरेंड से छोटा है या उसके बराबर है।

Example:

int A = 10, B = 5;
printf("%d", A <= B);

Output:

0

C Program to Demonstrate Relational Operators

रिलेशनल ऑपरेटर्स को प्रदर्शित करने वाला C प्रोग्राम

The following program demonstrates all six relational operators using two integer variables.

निम्न प्रोग्राम दो Integer Variables की सहायता से सभी छह रिलेशनल ऑपरेटर्स को प्रदर्शित करता है।

Program:

#include <stdio.h>
int main(void)
{
int A = 10, B = 5;
printf("A == B : %d\n", A == B);
printf("A != B : %d\n", A != B);
printf("A > B : %d\n", A > B);
printf("A < B : %d\n", A < B);
printf("A >= B : %d\n", A >= B);
printf("A <= B : %d\n", A <= B);
return 0;
}

Output:

A == B : 0
A != B : 1
A > B : 1
A < B : 0
A >= B : 1
A <= B : 0

Explanation:

Since A = 10 and B = 5:

  • A == B is false because 10 is not equal to 5.

  • A != B is true because 10 is not equal to 5.

  • A > B is true because 10 is greater than 5.

  • A < B is false because 10 is not less than 5.

  • A >= B is true because 10 is greater than 5.

  • A <= B is false because 10 is not less than or equal to 5.

व्याख्या:

चूँकि A = 10 तथा B = 5 हैं:

  • A == B असत्य है क्योंकि 10 और 5 बराबर नहीं हैं।

  • A != B सत्य है क्योंकि 10 और 5 अलग-अलग हैं।

  • A > B सत्य है क्योंकि 10, 5 से बड़ा है।

  • A < B असत्य है क्योंकि 10, 5 से छोटा नहीं है।

  • A >= B सत्य है क्योंकि 10, 5 से बड़ा है।

  • A <= B असत्य है क्योंकि 10, 5 से छोटा या बराबर नहीं है।

Truth Table of Relational Operators (रिलेशनल ऑपरेटर्स की ट्रुथ टेबल)

The following table shows the results of relational comparisons when two operands are equal or when one is greater than the other.

निम्न तालिका में दो ऑपरेंड्स के बराबर होने अथवा एक के दूसरे से बड़ा होने पर रिलेशनल ऑपरेटर्स के परिणाम दर्शाए गए हैं।

Condition==!=><>=<=
A = B100011
A > B011010
A < B010101

Important Points for Exams (परीक्षाओं के लिए महत्वपूर्ण बातें)

  1. There are six relational operators in C: ==, !=, >, <, >=, and <=.
    C में छह रिलेशनल ऑपरेटर्स होते हैं।

  2. Relational operators are binary operators.
    रिलेशनल ऑपरेटर्स बाइनरी ऑपरेटर्स होते हैं।

  3. Relational expressions produce an integer result: 1 for true and 0 for false.
    रिलेशनल एक्सप्रेशन्स का परिणाम True होने पर 1 तथा False होने पर 0 होता है।

  4. The == operator is used for comparison, whereas = is used for assignment.
    == का उपयोग तुलना के लिए तथा = का उपयोग मान असाइन करने के लिए होता है।

  5. The >= operator means greater than or equal to, not just greater than.
    >= का अर्थ बड़ा या बराबर होता है।

  6. The <= operator means less than or equal to, not just less than.
    <= का अर्थ छोटा या बराबर होता है।

  7. Relational operators are frequently used in if, if...else, and loop conditions.
    रिलेशनल ऑपरेटर्स का उपयोग if, if...else तथा लूप्स की कंडीशन में किया जाता है।

Relational operators are important in C programming because they help compare values and make decisions based on conditions. They are commonly used in decision-making statements and loops.

C प्रोग्रामिंग में रिलेशनल ऑपरेटर्स महत्वपूर्ण हैं क्योंकि इनकी सहायता से मानों की तुलना की जाती है तथा कंडीशन के आधार पर निर्णय लिए जाते हैं। इनका उपयोग मुख्य रूप से Decision-Making Statements तथा Loops में किया जाता है।

Comments

Popular posts from this blog

C Language Topics in Hindi and English

Complete C Programming Syllabus | Advanced C Roadmap for Students

Top High-Paying Tech Skills to Learn in 2025