LOGICAL OPERATORS IN C PROGRAMMING :-
LOGICAL OPERATORS In C Programming (लॉजिकल ऑपरेटर्स ) :-
दोस्तों आज के पाठ में हम C Programming के Logical Operators के बारे में पढ़ेंगे | Logical operators का उपयोग दो अलग-अलग conditions को combine करके logical operations perform करने के लिए किया जाता है |
C Programming में तीन प्रकार के Logical Operators होते है :-
- && ( इसे logical AND कहते है | )
- || ( इसे logical OR कहते है | )
- ! ( इसे logical NOT कहते है | )
- Logical OR Operators :- माना x और y दो अलग-अलग variable है और x में हम True value जमा कर देते है ( x = True ) और y में हम False जमा कर देते है ( y = False ) तो x || y करने पर हमे Output True मिलेगा | अगर y = True और x = False होता तब भी हमे x || y करने पर Output True ही मिलता |
साथ ही अगर x = True और y = True होता तब भी हमे Output True ही मिलता | लेकिन अगर x और y दोनों False होता ( x = False y = False ) तो output False मिलेगा |
आप नीचे के Table में || (LOGICAL OR) के सभी Condition को देख सकते है |
| Condition 1 | Condition 2 | Condition 1 || Condition 2 | |||||||||||||||
| True | True | True | |||||||||||||||
| True | False | True | |||||||||||||||
| False | True | True | |||||||||||||||
| False | False | False
Example:- Example Of Logical Operators in Hindi
#include <stdio.h>
int main()
{
int m=40,n=20;
int o=20,p=30;
if (m>n && m !=0)
{
printf("&& Operator : Both conditions are true\n");
}
if (o>p || p!=20)
{
printf("|| Operator : Only one condition is true\n");
}
if (!(m>n && m !=0))
{
printf("! Operator : Both conditions are true\n");
}
else
{
printf("! Operator : Both conditions are true. " \
"But, status is inverted as false\n");
}
}
|
कोई टिप्पणी नहीं:
एक टिप्पणी भेजें