हिंदी माध्यम नोट्स
Categories: c++ language in hindi
C++ : Special Operators in hindi , what are Special Operator in c++ language with programs examples
what are Special Operator in c++ language with programs examples , C++ : Special Operators in hindi :-
इससे पहले के article मे , increment , decrement और sizeof() operator को discuss किया है | अन इस article मे कुछ और विशेष operators को discuss करेगे | जिससे आपके programming skills बढ़ेगी |
1. Comma operator
comma operator का use c++ language मे दो प्रकार से use किया जा सकता है | इसका syntax है :-
‘,’ ;
यहा पर comma operator को प्रकार को निन्म प्रकार से use किया जाता है :-
1. As operator
जब comma operator को operator की तरह use किया जाता है तब ये binary operator की तरह use किया जाता है | इसमें पहले operand को दुसरे operand से अलग करने के लिए comma operator को use किया जाता है | इसके लिए निन्म उदाहरन है :-
#include<iostream.h>
#include<conio.h>
void main()
{
int a={3,6};
cout<<“value of a:”<<a;
}
getch();
}
इस उदाहरण मे , a मे 3 की value assign की जाती है और बाद मे comma operator से a मे ‘6’ की value assign की जाती है | इसका आउटपुट होगा :
value of a : 6
2. As Separator
comma operator को separator की तरह भी use किया जा सकता है | comma operator को निन्म तरह से seperator की तरह use किया जा सकता है :-
1.function मे argument को seperate करने के लिए |
2.variable declare करने के लिए |
3.Enum की value को define करने के लिए |
4.macro को define करने के लिए किया जाता है |
इसके लिए निन्म उदाहरन मे सभी topic को discuss किया है :-
#include<iostream.h>
#include<conio.h>
int add(int , int );
void main()
{
int a,b,c;
cout<<“Enter a :”<<endl;
cin>>a;
cout<<“Enter b : “<<endl;
cin>>b;
c= add(a,b);
cout<<“value of c:”<<c;
}
getch();
}
int add (int e,int f )
{
int sum ;
sum =e+f;
return (sum ) ;
}
इस उदाहरण मे
int a,b,c; – तीन variable a,b और c को देच्क्स्लारे करने के लिए comma operator को use किया जाता है |
c= add(a,b); – इसमें function को call किया जाता है | इसमें pass argument a,b को comma operator से separate किया जाता है |
इसका आउटपुट होगा :
Enter a : 12
Enter b : 13
value of c: 25
Condition Operator
condition operator c++ language मे एक मात्र tinary operator है | अतः इसमें तीन operand को use किया जाता है | इसके syntax होता है :-
(condition)? true_statement ; false_statement ;
यहा पर
condition : ये condition को check किया जाता है | अगर condition true होती है तब true_statement perform होता है | अन्यथा condition false होती है |
true_statement : ये true statement होता है जो की condition को true होने पर return होती है |
false_statement : ये false_statement होता है जो की condition के false होने पर return होती है |
इसका उदाहरन होता है :-
#include<iostream.h>
#include<conio.h>
int compare (int , int );
void main()
{
int a,b,c;
cout<<“Enter a :”<<endl;
cin>>a;
cout<<“Enter b : “<<endl;
cin>>b;
c= compare (a,b);
cout<<“Smaller value :”<<c;
}
getch();
}
int compare (int e,int f )
{
return ((e<f):e:f;) ;
}
इस उदाहरन मे , दो value के बीच compare किया जाता है | इसमें यूजर define function को use किया जाता है | इसमें condition operator को use किया जाता है |
जब a<b की condition को true होती है तब ‘a’ return होती है |
और a<b की condition false होती है तब ‘b’ return होती है |
इसका आउटपुट होता है :-
Enter a : 16
Enter b : 13
Smaller value : 13
Address Operator
इससे पहले के article मे pointer variable को use किया जाता है जो की किसी दुसरे variable के address को hold करता है | और pointer variable की value किसी variable के address को define करता है | लेकिन c/c++ language मे address operator होता है जो की किसी भी variable के address को define करता है |इसका syntax होता है :-
&variable name ;
यहा पर variable name variable का नाम है जिसका address को calculate किया जाता है |
इसका उदाहरन होता है :-
#include<iostream.h>
#include<conio.h>
void main()
{
int a;
char c;
double b;
float f;
cout<<“Enter Integer Value :”<<endl;
cin>>a;
cout<<“Enter Character Value :”<<endl;
cin>>c;
cout<<“Enter Flaot Value :”<<endl;
cin>>f;
cout<<“Enter Double Value :”<<endl;
cin>>d;
cout<<“Value of a: “<<a<<“And Address of a :”<<&a<<endl;
cout<<“Value of b: “<<b<<“And Address of b :”<<&b<<endl;
cout<<“Value of c: “<<c<<“And Address of c :”<<&c<<endl;
cout<<“Value of f: “<<d<<“And Address of f :”<<&f<<endl;
getch();
}
इसका आउटपुट होगा :-
Enter Integer Value : 15
Enter Character Value : f
Enter Float Value : 16.23
Enter Double Value : 15.200
Value of a: 15 And Address of a : 4000
Value of b: 15.200 And Address of b : 4008
Value of c: f And Address of c : 4010
Value of f: 16.23 And Address of f : 4018
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