हिंदी माध्यम नोट्स
C++ : Type Conversion in hindi , Type conversion by assignment operator , Conversion in Expression c++ language
int b=3.223;
int c=3.445e8;
cout<<“value of b : “<<b<<endl;
cout<<“value of c : “<<c<<endl;
bigger floating point type to smaller floating point type :- double to float | Result will be undefined. Output must be out of range for target type. |
Floating point type to integer type | In this case , fractional value will be eliminated |
Bigger integer type to smaller integer type | Result will be undefined. Output must be out of range for target type. |
char b=a;
int c= a+b;
cout<<“value of b : “<<b<<endl;
cout<<“value of c : “<<c<<endl;
इस type के conversion की limit होती है :
1.unsigned short type ,integer मे convert हो जाता है अगर short type इन्त्गेर से छोटी है |
2.अगर short और integer दोनों same size की होगी तब unsigned short ,unsigned integer मे convert हो जाता है |
3.जब integer त्योए को float के साथ use किया जाता है तब छोटी value ,बड़ी value मे convert हो जाती है |
4.अगर दोनों operand मे से एक long double type हो तब non long double type , long double मे convert हो जाता है |
5.अगर दोनों operand मे से एक double type हो तब non double type , double मे convert हो जाता है |
6.अगर दोनों operand मे से एक float type हो तब non float type , float मे convert हो जाता है |
7.अगर दोनों operand मे से एक integer type हो तब inter changable हो सकता है |
8.अगर दोनों integer मे से एक unsigned integer है तब signed integer , unsigned integer मे convert हो जाता है |
9.अगर एक unsigned और दूसरा long type है तब conversion दोनों variable की size पर निर्भर करता है |
10.अगर दोनों integer मे से एक long integer है तब integer , long integer मे convert हो जाता है |
C++ उपर दिए सभी type conversion के rules को फॉलो करता है लेकिन K&R C language मे कुछ और rule होता है |
उदाहरण होगा :
long int b= 677;
int c= a+b;
cout<<“value of b : “<<b<<endl;
cout<<“value of c : “<<c<<endl;
Type Cast
C++ मे manually type conversion possible है इसका syntax होता है :
type(variable name );
यहा पर
type : ये convert करने के दिए गये data type को define करता है |
variable name : ये variable का नाम है जिसे convert करना है |
C language मे type conversion का syntax थोडा change होता है इसका syntax होता है :
(type)variable name ;
उदाहरण के लिए :
int a,b;
float c;
cin>>a;
cout<<“Enter Value 2″<<endl;
cin>>b;
c=a/b;
cout<<“Value of output”<< int(c) << endl;
int d= a+b;
cout<<“Value of Addition :”<< d << endl;
इस article मे type conversion के आटोमेटिक और manually conversion को discuss किया है आगे वाले article मे compound data type को discuss करेगे |
Recent Posts
मालकाना का युद्ध malkhana ka yudh kab hua tha in hindi
malkhana ka yudh kab hua tha in hindi मालकाना का युद्ध ? मालकाना के युद्ध…
कान्हड़देव तथा अलाउद्दीन खिलजी के संबंधों पर प्रकाश डालिए
राणा रतन सिंह चित्तौड़ ( 1302 ई. - 1303 ) राजस्थान के इतिहास में गुहिलवंशी…
हम्मीर देव चौहान का इतिहास क्या है ? hammir dev chauhan history in hindi explained
hammir dev chauhan history in hindi explained हम्मीर देव चौहान का इतिहास क्या है ?…
तराइन का प्रथम युद्ध कब और किसके बीच हुआ द्वितीय युद्ध Tarain battle in hindi first and second
Tarain battle in hindi first and second तराइन का प्रथम युद्ध कब और किसके बीच…
चौहानों की उत्पत्ति कैसे हुई थी ? chahamana dynasty ki utpatti kahan se hui in hindi
chahamana dynasty ki utpatti kahan se hui in hindi चौहानों की उत्पत्ति कैसे हुई थी…
भारत पर पहला तुर्क आक्रमण किसने किया कब हुआ first turk invaders who attacked india in hindi
first turk invaders who attacked india in hindi भारत पर पहला तुर्क आक्रमण किसने किया…