Logical Operators In C Programming In Hindi With Example

Logical Operators In C Programming In Hindi With Example :

Logical Operators In C Programming In Hindi With Example

logical operators in c programming in hindi with example

NOTE – “Logical Operators In C Programming With Example” , Video को हमारे YouTube channel  में देखने के लिए इस Link में Click करें  । (Padhai Ki Batein /  पढाई की बातें)

C या C++ Programming में Logical operators का Use दो या दो से अधिक Conditions को Combine कर Check करने के लिए किया जाता हैं। Logical operators का ज़्यादातर Use Multiple Conditions को Check करने में होता हैं। ये मुख्य रूप से तीन प्रकार के होते हैं।

  1. AND (&&) 
  2. OR (||) 
  3. NOT (!)

AND logical operators

AND logical operator का Use दो या दो से अधिक Conditions को एक साथ Check करने के लिए किया जाता हैं। लेकिन AND logical operator की ख़ास बात यह हैं कि इसके साथ Define की गई सारी Conditions के एकदम सही होने पर ही Result True होता हैं । अगर Define की गई सभी Conditions में से , कोई एक Condition भी गलत हो जाती हैं तो Result False हो जायेगा। 

For Example 1. 

 if(p>=45) && (p<60)

cout<<“Second”;

else 

cout<<“Fail”;

उपरोक्त Example में P में Store Value अगर 45 या 45 से ज्यादा मगर 60 से कम होगी तभी Computer “Second” Print करेगा नही तो “Fail” Print कर देगा। यानि यहां पर दोनों Conditions एकदम सही होनी चाहिए तभी “Second” Print  होगा। एक भी Condition के गलत होने पर Computer Else Path को Check करना शुरू कर देगा यानि “Fail” Print कर देगा

For Example 2 .

 if((a>=30) && e==’m’))

cout<<“PGT”;

else 

cout<<“TGT”;

उपरोक्त Example में अगर a में Store Value , 30  या 30 से ज्यादा होगी और e Variable में “m” Value Store होगी , तभी Computer “PGT” Print करेगा नही तो “TGT” Print कर देगा। यानि यहां पर भी दोनों Conditions एकदम सही होनी चाहिए तभी “PGT” Print  होगा वरना “TGT” Print होगा। NOTE – logical operators में True के लिए (1) और False के लिए (0) लिखा जाता हैं।

OR logical operators

OR logical operator का Use भी दो या दो से अधिक Conditions को एक साथ Check करने के लिए किया जाता हैं। लेकिन OR logical operator की ख़ास बात यह हैं कि अगर इसके साथ दो Conditions Define की गई हैं तो उसमें से किसी एक Condition के सही होने पर भी Result True होगा। यानि OR logical operator में दोनों Conditions के सही होने की कोई जरूरत नही हैं। इसमें Condition तभी False होगा जब दोनों ही Condition गलत हो जायेंगी ।  

For Example – 

 if((a>=45) && (w>=10) || (w>=10 && E==’m’))

cout<<“PGT”;

else 

cout<<“TGT”;

उपरोक्त Example में If के साथ दो Conditions दी गई हैं । एक OR logical operator के Left Side और एक Right Side .

  1. पहली Condition (Left Side) में , अगर a में Store Value 45 या 45 से ज्यादा हैं और w में Store Value 10 या 10 से ज्यादा हैं।
  2. दूसरी  Condition ( Right Side) में , अगर w में Store Value 10 या 10 से ज्यादा हैं और e में “m” Character Store हैं।

यहाँ पर दोनों Conditions के बीच में OR logical operators लगा हैं तो यहां पर दोनों Conditions में से कोई एक Condition भी सही होगी तो Result “PGT” Print हो जायेगा यानि यहां पर दोनों Conditions के सही होने की कोई जरूरत नहीं हैं । किसी एक के सही होने पर भी Result True होगा।

यहां पर Result “TGT” तभी Print होगा जब दोनों ही Conditions False हो जायेंगी। 

NOT logical operators

NOT logical operator में Result बुलियन Type होता हैं। अगर Condition सही होती हैं तो NOT logical operator उसे False बनाकर Result भी False ही Return करता हैं। इसी तरह Condition के गलत होने पर उसे सही मान कर True Result Return करता हैं। यानि इसमें Result Reverse Return होता हैं। 

For Example 1. 

int a =100 , b=50 ;

if(!a>=50)

या

if(!a>=b)

cout <<“A” ;

else

cout <<“B” ;

उपरोक्त Example में दी गई Conditions एकदम सही हैं मगर Computer False Path Print करेगा।

 AND Logical Operators With Example

#include<iostream.h>

#include<conio.h>

void main()

{

clrscr() ;

char sn [10];

int h , e , m , s , t , p ;

cout <<“Enter Student’s Name     =   ” ;

cin>>sn;

cout <<“Hindi Marks   ” ;

cin>>h ;

cout <<“English Marks   =  ” ;

cin>>e ;

cout <<“Maths Marks   =   ” ;

cin>>m ;

cout <<“Science  Marks   =   ” ;

cin>> s ;

t=h+e+m+s ;

p=t/4;

clrscr() ;

cout <<“                      Marks Sheet”<<“\n” ;

cout<<“Marks in Hindi       =  “<<h <<“\n”;

cout<<“Marks in Science    =  “<<s<<“\n” ;

cout<<“Marks in Maths      =  “<<m<<“\n” ;

cout<<“Marks in English    =  “<<e<<“\n” ;

cout<<“Total Marks           =  “<<t<<“\n” ;

cout<<“Percentage           =  “<<p<<“\n” ;

if(p>=60)

cout<<“First”;

Else if(p>=45 && p<60)

cout<<“Second”;

Else if (p>=33 && p<45)

cout<<“Third”;

else

cout<<“Fail”;

getch();

}

Example 2.

OR Logical Operators With Example

#include<iostream.h>

#include<conio.h>

void main()

{

clrscr() ;

char q 10];

int w , a ;

cout <<“Enter Student’s Qualification   ” ;

cin>>q;

cout <<“Enter Student’s Age   ” ;

cin>>a ;

cout <<“Enter Student’s Work Experience  ” ;

cin>>w ;

if((a>=30 && w>=10) || (w>=10 && q==’m’))

cout<<“Eligible For PGT”;

Else 

cout<<“Eligible For TGT”;

getch();

}

Logical Operators In C Programming With Example In Hindi ,

“Logical Operators In C Programming With Example” , Video को हमारे YouTube channel  में देखने के लिए इस Link में Click करें  ।   YouTube channel link –  (Padhai Ki Batein /  पढाई की बातें)

NOTE – Class 8th , 9th , 10th , 11th , 12th के हिन्दी विषय के सभी Chapters से संबंधित videos हमारे YouTube channel (Padhai Ki Batein /  पढाई की बातें) पर भी उपलब्ध हैं। कृपया एक बार अवश्य हमारे YouTube channel पर visit करें । सहयोग के लिए आपका बहुत – बहुत धन्यबाद।

You are most welcome to share your comments . If you like this post . Then please share it . Thanks for Reading.

यह भी पढ़ें

  1. C और C++ क्या हैं ?
  2. C या C++ में पहला Program कैसे बनाते हैं ?
  3. Difference Between If And If Else Statement In C
  4. 6 Small And Simple Programs For Beginners
  5. If And If Else Statement in C
  6. If Else Statement in C
  7. Nested If Else Statement In C
  8. Find Out the Largest Value of any given four And Three Numbers in C
  9. What is HTML Coding
  10. Web Page कैसे बनाते हैं
  11. HTML Form 
  12. How To Create Table In Html
  13. How To Create Hyperlink In HTML
  14. How To Insert An Image In HTML Page
  15. Ordered And Unordered List In HTML
  16. Frame In HTML Coding
  17. Add Background Color And Image
  18. Map in HTML
  19. Nested List In HTML
  20. How To Create A Website Using HTML Only On Notepad No CSS Used
  21. How TO Create A Beautiful And Simple WebPage Using HTML Only (No CSS Used)