JOIN us on
WhatsApp Group Join Now
Telegram Join Join Now

हिंदी माध्यम नोट्स

Categories: c++ language in hindi

C++ : Relation Operator , larger than , Smaller than , Smaller and equal than , not equal operators in c++ language

larger than , Smaller than , Smaller and equal than , not equal operators in c++ language ,  C++ : Relation Operator :-
इससे पहले एक article मे c++ मे उपस्थित सभी data type को discuss कर लिए है | लेकिन केवल arithmetic operator को discuss किया है | अब इस article मे relation operator को discuss करेगे |
Operator
c++ मे operators को basically दो प्रकार से divide किया जाता है :-
इस category मे पांच  arithmetic operators है जिसमे addition,subtraction , multiplication , division, और modules है | इन सभी को हम पहले अच्छी तरह से discuss कर चुके है |
2. Relation operator
जब किसी प्रोग्राम मे दो या दो से अधिक values को compare किया जाता है तब इस operator को use किया जाता है | इस category मे पांच  Relation operator है | जब किसी expression मे Relation operator को use किया जाता है तब इसे Relation expression कहते है | सभी  Relation expression की value boolean होती है | अथात इसकी true और false value होती है |
1. larger than
इस operator का use किसी  दो values मे compare करने के लिए use किया जाता है | इसका syntax ‘>’ होता है | इसमें first > second statement से मतलब होता है
first value का compare second value से होता है | अगर first value , second value से बड़ी होती तब इस expression का आउटपुट ‘1’ होता है  अन्यथा ‘0’ होती है |
इसका उदाहरण होता है :-
#include<iostream.h>
#include<conio.h>
void main()
{
int a,b;
bool t;
cout<<“Enter First Value :”<<endl;
cin>>a;
cout<<“Enter Second Value :”<<endl;
cin>>b;
t=(a>b);
if(b=’TRUE’)
{
cout<<“Largest value : “<< a <<endl;
}
else
cout<<“Largest value : “<<b<<endl;
getch();
}
इस उदाहरण मे दो variable को declare किया जाता है | जिसको variable ‘a’ और ‘b’ मे assign कर दिया जाता है |
और (a>b) expression के आउटपुट को variable  t मे assign कर देते है | इस variable का type boolean है |
अगर variable ‘t’ की value ‘1’ होती है तब Largest value :a print होगा |
अन्यथा  Largest value :  b display होता है |
इसका आउटपुट होगा
Enter First Value : 12
Enter Second Value : 23
Largest value : 23
2. Smaller than
इस operator का use किसी  दो values मे compare करने के लिए use किया जाता है | इसका syntax ‘<‘ होता है | इसमें first < second statement से मतलब होता है
first value का compare second value से होता है | अगर first value , second value से छोटी होती तब इस expression का आउटपुट ‘1’ होता है  अन्यथा ‘0’ होती है |
इसका उदाहरण होता है :-
#include<iostream.h>
#include<conio.h>
void main()
{
int a,b;
bool t;
cout<<” First Value :”<<endl;
cin>>a;
cout<<” Second Value :”<<endl;
cin>>b;
t=(a<b);
if(b=’TRUE’)
{
cout<<“First value is small that Second Value .”<<endl;
cout<<“Smaller value : “<< a <<endl;
}
cout<<“Second Value is small that First Value .”<<endl;
cout<<“Smaller value : “<<b<<endl;
getch();
}
इस उदाहरण मे दो variable को declare किया जाता है | जिसको variable ‘a’ और ‘b’ मे assign कर दिया जाता है |
और (a<b) expression के आउटपुट को variable  t मे assign कर देते है | इस variable का type boolean है |
अगर variable ‘t’ की value ‘1’ होती है तब First value is small that Second Value. और a की value print होगा |
अन्यथा  Second Value is small that First Value . और ‘b’ की value print display होता है |
इसका आउटपुट होगा
Enter First Value : 12
Enter Second Value : 23
First value is small that Second Value .
Smaller value : 12
3. Smaller and equal than
इस operator से दो variables मे  smaller and equal की condition को  check किया जाता है | इसका syntax ‘<=’ होता है | इसमें first <=second statement से मतलब होता है first value का compare second value से होता है | अगर first value , second value से छोटी  या समान होती तब इस expression का आउटपुट ‘1’ होता है  अन्यथा ‘0’ होती है |
इसका उदाहरण होता है :-
#include<iostream.h>
#include<conio.h>
void main()
{
int a,b;
bool t;
cout<<” First Value :”<<endl;
cin>>a;
cout<<” Second Value :”<<endl;
cin>>b;
t=(a<=b);
if(b=’TRUE’)
{
cout<<“First value is small and equal than Second Value .”<<endl;
if(a<b)
{
cout<<“Smaller value : “<< a <<endl;
cout<<“Larger value : “<< b <<endl;
}
else
{
cout<<“Both values are same .”;
}
}
if(a>b)
{
cout<<“Smaller value: “<< b <<endl;
cout<<“Larger value : “<< a <<endl;
}
else
{
cout<<“Both values are same .”;
}
getch();
}
इस उदाहरण मे दो variable को declare किया जाता है | जिसको variable ‘a’ और ‘b’ मे assign कर दिया जाता है |
और (a<=b) expression के आउटपुट को variable  t मे assign कर देते है | इस variable का type boolean है |
अगर variable ‘t’ की value ‘1’ होती है तब एक और condition (a<b) को check किया जाता है | अब इस condition के true होने पर  smaller value और larger value को display किया जाता है  |
इसका आउटपुट होगा
Enter First Value : 12
Enter Second Value : 23
First value is small or equal than Second Value .
Smaller value : 12
Larger value : 23
4. Not Equal
इस operator से दो variables मे  equality की condition को  check किया जाता है | इसका syntax ‘!=’ होता है | इसमें first !=second statement से मतलब होता है first value का compare second value से होता है | अगर first value , second value समान नहीं होती तब इस expression का आउटपुट ‘1’ होता है  अन्यथा ‘0’ होती है |
इसका उदाहरण होता है :-
#include<iostream.h>
#include<conio.h>
void main()
{
int a,b;
bool t;
cout<<” First Value :”<<endl;
cin>>a;
cout<<” Second Value :”<<endl;
cin>>b;
t=(a!=b);
if(b=’TRUE’)
{
cout<<“First value is not equal than Second Value .”<<endl;
}
else
{
cout<<“First value is equal than Second Value .”;
}
getch();
}
इस उदाहरण मे दो variable को declare किया जाता है | जिसको variable ‘a’ और ‘b’ मे assign कर दिया जाता है |
और (a>=b) expression के आउटपुट को variable  t मे assign कर देते है | इस variable का type boolean है |
अगर variable ‘t’ की value ‘1’ होती है तब First value is not equal than Second Value . display होगा अन्यथा  First value is equal than Second Value .
इसका आउटपुट होगा
Enter First Value : 12
Enter Second Value : 23
First value is not equal than Second Value .
5. larger  and equal than
इस operator से दो variables मे  larger and equal की condition को  check किया जाता है | इसका syntax ‘>=’ होता है | इसमें first >=second statement से मतलब होता है first value का compare second value से होता है | अगर first value , second value से बड़ी  या समान होती तब इस expression का आउटपुट ‘1’ होता है  अन्यथा ‘0’ होती है |
इसका उदाहरण होता है :-
#include<iostream.h>
#include<conio.h>
void main()
{
int a,b;
bool t;
cout<<” First Value :”<<endl;
cin>>a;
cout<<” Second Value :”<<endl;
cin>>b;
t=(a>=b);
if(b=’TRUE’)
{
cout<<“First value is smaller and equal than Second Value .”<<endl;
if(a<b)
{
cout<<“Smaller value : “<< a <<endl;
cout<<“Larger value : “<< b <<endl;
}
else
{
cout<<“Both values are same .”;
}
}
if(a>b)
{
cout<<“Smaller value: “<< b <<endl;
cout<<“Larger value : “<< a <<endl;
}
else
{
cout<<“Both values are same .”;
}
getch();
}
इस उदाहरण मे दो variable को declare किया जाता है | जिसको variable ‘a’ और ‘b’ मे assign कर दिया जाता है |
और (a>=b) expression के आउटपुट को variable  t मे assign कर देते है | इस variable का type boolean है |
अगर variable ‘t’ की value ‘1’ होती है तब एक और condition (a>b) को check किया जाता है | अब इस condition के true होने पर  smaller value और larger value को display किया जाता है  |
इसका आउटपुट होगा
Enter First Value : 12
Enter Second Value : 23
First value is smaller or equal than Second Value .
Smaller value : 12
Larger value : 23
Sbistudy

Recent Posts

मालकाना का युद्ध malkhana ka yudh kab hua tha in hindi

malkhana ka yudh kab hua tha in hindi मालकाना का युद्ध ? मालकाना के युद्ध…

4 weeks ago

कान्हड़देव तथा अलाउद्दीन खिलजी के संबंधों पर प्रकाश डालिए

राणा रतन सिंह चित्तौड़ ( 1302 ई. - 1303 ) राजस्थान के इतिहास में गुहिलवंशी…

4 weeks ago

हम्मीर देव चौहान का इतिहास क्या है ? hammir dev chauhan history in hindi explained

hammir dev chauhan history in hindi explained हम्मीर देव चौहान का इतिहास क्या है ?…

4 weeks ago

तराइन का प्रथम युद्ध कब और किसके बीच हुआ द्वितीय युद्ध Tarain battle in hindi first and second

Tarain battle in hindi first and second तराइन का प्रथम युद्ध कब और किसके बीच…

4 weeks ago

चौहानों की उत्पत्ति कैसे हुई थी ? chahamana dynasty ki utpatti kahan se hui in hindi

chahamana dynasty ki utpatti kahan se hui in hindi चौहानों की उत्पत्ति कैसे हुई थी…

1 month ago

भारत पर पहला तुर्क आक्रमण किसने किया कब हुआ first turk invaders who attacked india in hindi

first turk invaders who attacked india in hindi भारत पर पहला तुर्क आक्रमण किसने किया…

1 month ago
All Rights ReservedView Non-AMP Version
X

Headline

You can control the ways in which we improve and personalize your experience. Please choose whether you wish to allow the following:

Privacy Settings
JOIN us on
WhatsApp Group Join Now
Telegram Join Join Now