हिंदी माध्यम नोट्स
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
सती रासो किसकी रचना है , sati raso ke rachnakar kaun hai in hindi , सती रासो के लेखक कौन है
सती रासो के लेखक कौन है सती रासो किसकी रचना है , sati raso ke…
16 hours ago
मारवाड़ रा परगना री विगत किसकी रचना है , marwar ra pargana ri vigat ke lekhak kaun the
marwar ra pargana ri vigat ke lekhak kaun the मारवाड़ रा परगना री विगत किसकी…
16 hours ago
राजस्थान के इतिहास के पुरातात्विक स्रोतों की विवेचना कीजिए sources of rajasthan history in hindi
sources of rajasthan history in hindi राजस्थान के इतिहास के पुरातात्विक स्रोतों की विवेचना कीजिए…
2 days ago
गुर्जरात्रा प्रदेश राजस्थान कौनसा है , किसे कहते है ? gurjaratra pradesh in rajasthan in hindi
gurjaratra pradesh in rajasthan in hindi गुर्जरात्रा प्रदेश राजस्थान कौनसा है , किसे कहते है…
2 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