What is Variable in Hindi – वेरिएबल क्या होता है?
- variable एक container होता है जो की data को hold करके रखता है।
- variable एक identifier , memory location या एक नाम है जो की किसी वैल्यू को स्टोर करता है। इसके value को बदला जा सकता है, और इसे कई बार दुबारा उपयोग किया जा सकता है।
- वेरिएबल का नाम केवल memory location का symbolic representation है।
- किसी वेरिएबल का नाम लिख़ने के लिए अधिक से अधिक 31 letters का उपयोग किया जाता है।
Rules for defining variables in Hindi – वेरिएबल को डिफाइन करने के नियम
- एक variable के नाम में केवल alphabets ( uppercase और lowercase) , digits और underscores हो सकते हैं।
- Variable की शुरुआत किसी भी alphabet(a-z, A-Z) या underscore( _ ) से हो सकती है लेकिन variable के नाम को किसी digit से शुरू नहीं कर सकते।
- Variable के नाम मे space को allow नहीं किया जा सकता।
- वेरिएबल का नाम एक keyword नहीं होना चाहिए। उदाहरण के लिए int , float , char ये keyword है इनका उपयोग वेरिएबल नाम के लिए नहीं कर सकते।
- C लैंग्वेज एक ये case-sensitive Language है | अतः वेरिएबल नाम जैसे school और SCHOOL दोनों अलग – अलग है।
Some example of Valid & Invalid variable
Example of Valid Variable :
- int age ;
- int class11 ;
- char MY_NAME = ‘technical’ ;
- int _Phone123 ;
Example of Valid Variable :
- int 52_number ; // क्योकि variable के नाम को किसी digit से शुरू नहीं कर सकते।
- char Your name = ‘notes’ : // क्योकि Variable के नाम मे space को allow नहीं किया जा सकता।
- int long ; // वेरिएबल का नाम एक keyword नहीं होना चाहिए |
Types of Variable – वेरिएबल के प्रकार
वेरिएबल मुख्य्तः दो प्रकार के होते है।
- Local Variable
- Global Variable
Local Variable
- वह variable जिसे फ़ंक्शन या block के अंदर define किया जाता है, उसे local variable कहते है।
- Local Variables की default value ‘garbage value’ होती है |
- local Variables की visibility केवल function के अंदर में होती है |
- उदाहरण :
void function1 ()
{
int age = 10; //local variable
}
- Program
Source Code : #include <stdio.h> int main() { int X = 52, Y = 16, Z; // Local Variable printf("Value of X : %d", X); printf("Value of Y : %d", Y); printf("Default Value of Z : %d", Z); return 0; } Output : Value of X : 52 Value of Y : 16 Default Value of Z : 16 // garbage value
Global Variable
- वह variable जिसे फ़ंक्शन या block के बाहर define किया जाता है, उसे global variable कहते है।
- Local Variables की default value ‘ zero (0) ‘ होती है |
- Global Variables की visibility पूरे program में होती है |
- उदाहरण :
int value=200; //global variable
void function2()
{
int A=100; //local variable
}
- Program
Source Code : #include <stdio.h> int a = 5, b = 6, c; // Global Variable int main() { printf("Value of a : %d", a); printf("Value of b : %d", b); printf("Default Value of c : %d", c); return 0; } Output : Value of a : 5 Value of b : 6 Default Value of c : 0
RECOMMENDED POST :
- Introduction in C language in Hindi
- Difference Between POP and OOP Language in Hindi ?
- printf () & scanf () Function in Hindi
- Keywords & Identifiers in C in Hindi