हिंदी माध्यम नोट्स
Categories: c++ language in hindi
C++ : Character Type in hindi , what are Character Types in c++ language in hindi , symbol , programe
what are Character Types in c++ language in hindi , symbol , programe , C++ : Character Type in hindi :-
character data type का c++ का मुख्य data type है |हमने C language मे पढ़ा की char किसी signal character को store करता है |लेकिन C++ मे char data type मे दोनों character और digit को store कर सकता है |अतः char data type को integer का type भी कहते है |इस data type मे सभी सिम्बल्स – letters , digits, punctuation और आदि को store करने के लिए enough memory space होता है |
Symbol
Computer मे 256 characters होते है |इसे ASCII character set कहते है |उदाहरण के लिए 65 का character ‘A’ होता है | अतः char data type 65 के लिए “A” को ही store करता है |उदाहरण के लिए :
#include<iostream.h>
#include<conio.h>
#include<conio.h>
void main()
{
using nameapace std;
using nameapace std;
char c;
cout<<“Enter Character”<<endl;
cin>>c;
cout<<“Welcome”<<c<<“in the world of C++.”<<endl;
getch();
}
इस उदाहरण मे , ‘c’ एक character type data है जिसमे यूजर द्वारा दिए जाने वाले character को store किया जाता है |
आउटपुट होगा :
Enter Character P
Welcome P in the world of C++.
यहा पर P का character code 80 है |आउटपुट मे “P” मे print होगा |लेकिन जब memory से डील करते है तब memory location मे 80 store होता है |Cin और Cout statement आटोमेटिक character data type को integer data मे convert कर सकते है |यहा cin से character data type को integer मे convert कर देता है | Cout से integer data type को character data type मे convert कर देते है |अगर P को single quota मे क्लोज करे तो इसके integer value को print करता है |
उदाहरन के लिए
#include<iostream.h>
#include<conio.h>
#include<conio.h>
void main()
{
using nameapace std;
using nameapace std;
char c;
int i;
cout<<“Enter Character”<<endl;
cin>>c;
cout<<“Welcome”<<c<<“in the world of C++.”<<endl;
cout<<“ASCII Value of c”<<i<<endl;
i=c;
c=c+1;
cout<<“ASCII Value of c”<<i<<endl;
cout<<“ASCII Value of c”<<c<<endl;
getch();
}
इस उदाहरण मे यूजर द्वारा input की जाने value ‘P’ है इसे ‘c’ variable मे assign किया जाता है | अतः ‘c’ की ASCII value integer ‘i’ मे assign किया जाता है | cout statement -1 से character को print करता है | cout statement -2 से , ‘c’ की ASCII value को print करता है |
cout.put ()
ये function c++ के oops concept का पहला उदहारण है |इसे member function भी कहते है |member function मुख्य class, ( किस तरह से data को manage करना है )को guide करता है |ostream एक एसी class है जिसमे put() function को use किया जाता है |इस function को ostream class के केवल एक function cout के साथ ही use किया जा सकता है | cout और put () function को एक साथ use के लिए period को use किया जाता है |इसे membership operator कहते है |syntax होता :
cout.put();
cout.puts का use << के स्थान पर किया जाता है | इसका मुख्य इस्तेमाल charecter के लिए किया जाता है |
Why cout.put()
जब C++ का 2.0 version release किया गया तब cout statement से character variable को character और character constant को number की तरह display करता है | जैसे “P” की जगह 80 को display करता है |ये प्रॉब्लम C++ 2.0 version से पहले आती थी |इस प्रॉब्लम को solve करने के लिए put() member function को बनाया गया | उदाहरण के लिए
#include<iostream.h>
#include<conio.h>
#include<conio.h>
void main()
{
using nameapace std;
using nameapace std;
char c;
char ch;
cout<<“Enter Character”<<endl;
cin>>c;
cout<<“Welcome”<<c<<“in the world of C++.”<<endl;
cout<<“Enter Character Constant”<<endl;
cin>>ch;
cout.put(ch);
getch();
}
अगर cout<<‘ch’; को use किया जाता तब Character Constant के ASCII value print होती है लेकिन cout.put(ch); से Character Constant , एक character के तरह treat होती है | और character print होता है |
Character Constant
Character Constant एसे character होते है जिनकी value constant होती है | सभी single character जी की single quote मे क्लोज होते है एक Character Constant होते है |उदाहरण के लिए :
The ASCII of ‘A’ : 65
The ASCII of ‘a’ : 97
The ASCII of 5 : 53
The ASCII of ‘ ‘ : 32
The ASCII of ‘!’ : 33
इस उदाहरन से देखा जा सकता है की “a” की value 97 है | यहा पर 97 ‘a’ का code नहीं है बल्कि ‘a’ अभी भी एक character है |लेकिन ये integer value का use memory मे store होने के लिए किया जाता है |
Character और spacial character के अलावा सभी escape code के भी ASCII value होती है जो की निन्म table मे है :
Character name | ASCII Symbol | C++ code | ASCII Decimal Code | ASCII Hex code |
newline | NL | \n | 10 | 0xA |
Horizontal tab | HT | \t | 09 | 0x9 |
Vertical Tab | VT | \v | 11 | 0xB |
Backspace | BS | \b | 8 | 0x8 |
Carriage Return | CR | \r | 13 | 0xC |
Alert | BEL | \a | 7 | 0x7 |
Backlash | \ | \\ | 92 | 0x5C |
Universal Character Name
प्रोग्रामर द्वारा उपर discuss किये गये सभी chrecter को use कर सकता है | जैसे declare character ,character constant , escape character और many more |लेकिन C++ मे इन सभी के अलावा एक और category होती है जिसे universal character कहते है | इसे ISO द्वारा define किया गया है |
इसकी starting \u और \U से होती है और ये 8 hexadecimal से मिल कर बनता है |उदाहरण के लिए
int k\u00E2pple;
cout<<“Universal Character is \u00E2pple”<<endl;
ISO मे सभी universal character के लिए एक code को define किया गया है |इस उदाहरण मे code ’00E2′ , france a code है |
Signed Or Unsigned Character
char का default type unsigned होता है | integer की तरह unsigned character की range भी बहुत बड़ी होती है | जैसे
signed character की range -128 से 127 होती है |
unsigned character की range 0 से 255 होती है |
इस article मे character data type को discuss किया है |अब C++ : Boolean Type मे Boolean data type को discuss करेगे |
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