Introduction to C++ Variables


Introduction to C++ Variables 

C++ Variables

C++ Variables


किसी भी तरह के data को computer memory में store करने के लिए आप variables का उपयोग करते है। आसान शब्दों में कहें तो variables किसी box की तरह होते है जिसमें आप values को store करते है। Technically variables एक computer memory location होती है जिसे एक नाम दिया जाता है और उस memory location पर values store की जाती है। बाद में इसी नाम को use करते हुए आप store की गयी value पर अलग अलग operations perform करते है।  

Variables की values change की जा सकती है। उदाहरण के लिए यदि आपने किसी variable में 5 store किया है तो आप इसे change करके 10 कर सकते है। ऐसा आप खुद manually भी कर सकते है या फिर किसी operation के द्वारा भी ऐसा किया जा सकता है। 

Creating Variables 
C++ में भी C language की तरह ही variables create किये जाते है। Variables create करने का general syntax निचे दिया जा रहा है। 

data_type variable_name;
   
C++ में variables create करने के लिए सबसे पहले आप ये define करते है की आप किस तरह की value उस variable में store करेंगे। ऐसा आप data type define करके करते है। Data type से compiler को पता चलता है की किस तरह की value एक particular variable में store की जायेगी, इस जानकारी के base पर compiler जितनी memory required होती है उतनी इस variable को allot करता है।
Data type define करने के बाद variable का एक unique नाम define किया जाता है। आप एक नाम के 2 variables नहीं create कर सकते है। जैसा की आपको पता है की C++ एक case sensitive language है, इसलिए upper case और lower case variables अलग अलग माने जाते है। उदाहरण के लिए age और Age दो different variables माने जायेंगे।
आइये अब C++ में variables create करना एक उदाहरण के माध्यम से समझने का प्रयास करते है।
int age;
ऊपर दिए गए उदाहरण में integer type का variable create किया गया है। इस variable का नाम age है।

Share this

Related Posts

Previous
Next Post »

please comment your choice game ...