हिंदी माध्यम नोट्स
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
Recent Posts
सती रासो किसकी रचना है , sati raso ke rachnakar kaun hai in hindi , सती रासो के लेखक कौन है
सती रासो के लेखक कौन है सती रासो किसकी रचना है , sati raso ke…
23 hours ago
मारवाड़ रा परगना री विगत किसकी रचना है , marwar ra pargana ri vigat ke lekhak kaun the
marwar ra pargana ri vigat ke lekhak kaun the मारवाड़ रा परगना री विगत किसकी…
24 hours ago
राजस्थान के इतिहास के पुरातात्विक स्रोतों की विवेचना कीजिए sources of rajasthan history in hindi
sources of rajasthan history in hindi राजस्थान के इतिहास के पुरातात्विक स्रोतों की विवेचना कीजिए…
3 days ago
गुर्जरात्रा प्रदेश राजस्थान कौनसा है , किसे कहते है ? gurjaratra pradesh in rajasthan in hindi
gurjaratra pradesh in rajasthan in hindi गुर्जरात्रा प्रदेश राजस्थान कौनसा है , किसे कहते है…
3 days ago
Weston Standard Cell in hindi वेस्टन मानक सेल क्या है इससे सेल विभव (वि.वा.बल) का मापन
वेस्टन मानक सेल क्या है इससे सेल विभव (वि.वा.बल) का मापन Weston Standard Cell in…
3 months ago
polity notes pdf in hindi for upsc prelims and mains exam , SSC , RAS political science hindi medium handwritten
get all types and chapters polity notes pdf in hindi for upsc , SSC ,…
3 months ago