Variables In C

Dear Students, aaj ke is Lecture me hum janege Variables In C ke bare main yani ke c language main variables kaise define karte hai. Or sath me variables kya hote hai variable de definition or types of variable aadi se related ye sare topic ham variables in C me cover karege.

Lectures Covering Topics

  • Definition Variables In C In Hindi
  • Declaration Of Variables In C In Hindi
  • Initialization Of Variables In C In Hindi
  • Rules Of Defining Variables In C
  • Types Of Variables In C

Students yadi aap kisi data ke sath operation perform karna chahate hai. To sabse pahle aapko use computer ki memory me store karna padta hai. Computer me data ko store karne ke liye variables ka use kiya jata hai.

Definition Of Variables In C In Hindi

Variable ek aisa naam hota hai jiska use ham value ko computer ki memory me store karne ke liye kar sakte hai. Variables ek time me different values le sakta hai. In values ko program ke execution time par change kiya jaa sakta hai. Us variables ka data type he decide karta hai ki variable ki type ka data store karega.

(Variable is a name that can be used to store values, it can take different values but one at a time. These values can be changed during execution of the program. A data type is associated with variable and it decides what values the variable can take.)

Note:- (Variable ke bare me samjhne se pahle aapko data type ke bare me pta hona chahiye. Agar aapko pta hai to aap variable in c lecture ko continue kar sakte hai. Agar aap data types ke bare me panda chahte hai to aap data types in c ke lecture ko pad lijiye.)

Click To Read Data Types In C In Hindi

Declaration Of Variables In C In Hindi

Ek variable create karne se pahle ham us variable ka data type define karte hai. Ye hame pata hona chahiye ki hame kis tarah ka data store karna hai.

Iske bad ham ek unique name define karege name ki number ya fir kisi symbols se start nahi hona chahiye. Jaise ki name kuch is tarah se rakh sakte hai value, value1, val_name aadi. C language me variable create karne ka syntax neeche diya hua hai.

  • Without assigning value:- <data type> <variable name>;
  • With assigning value:- <data type> <variable name> = <variable value>;

Examples ke liye neeche create kiye hue variables dekh lijiyega.

Upar diye first variables me int(number) type ka ek num name ka variable memory me create hua hoga. Joki koi bhi numeric value store kar sakta hai. According to second variable ye bhi int type ka ek num2 naam ka variable memory me create karega. Lekin iski value hamne pahle se he define  kar di hai jo ki 10 hai.

Initialization Of Variables In C In Hindi

Jab ham koi variable declare karte hai. To usme ek undefined value hoti hai jise ham log garbage value ka naam de dete hai. Agar ham chahate hai ki variable ko define karne ke time par variable me koi initial value assign ho ise ham initialization of variables kahte hai.

Like example:-

Rules Of Defining Variables In C In Hindi

Variable define karne se pahle hame kuch baton par dhyan dena bahut jaroori hai. Kyoki variable define karne ke kuch rules hote hai. Agar ham in rules ko follow nahi karte hai to compiler hamare program me error generate karta hai. There are some rule for defining variables in c-

  • Ek variable me digits, underscore, alphabets ho sakte hai.
  • Kisi variable ko underscore, alphabets se start kar sakte hai kisi number ya digits se nahi kar sakte.
  • Kisi variable me koi bhi white space allowed nahi hai.
  • Variable ka naam koi reserved keyword nahi hona chahiye jaise int, char, float.
  • Variables ko define karne se pahle variable ka data type jaroor hona chahiye.

Types Of Variables In C In Hindi

  • Local Variable
  • Global Variable
  • Static Variable
  • Automatic Variable
  • External Variable

Types Of Variables In C

Local Variable

Local variables wo variables hote hai. Jo program main kisi user define function, control statement block me define kiye jate hai. Is trah ke variables ki limit sirf usi block or function me rahti hai. Or ham local variables ko usi block me use kar sakte hai.

Block yani function ki starting me he variable ko declare kiya jana chahiye.

Just Like example-

Global Variable

Aise variable jinkka scope poore program me hota hai wo Global variable kahlate hai. Global variable ko aap poore program me kahi bhi access kar sakte ho. In variables ko program ke starting me hi define kiya jata hai.

Agar koi bhi kisi global variable ki value change karta hai. To fir wo value poore program ke liye change ho jati hai.

For example-

Static Variable

Kisi static variable ko declare karne ke liye hame variable se pahle static keyword use karna hota hai. Jis variable ke starting me static keyword use kiya jata hai us variable ko static variable kahte hai.

Agar ham kisi bhi function ko bar bar call karte hai to static variable ki change hui value ko use karta hai.

For example-

Yadi ham is function ko kai bar call karte hai. To local variable sabhi function ke liye same value print karta hai example 20, 20, 20. Lekin static variable sabhi function me apni value ko incremented value print karega karega jaise 21, 22, 23.

Automatic Variable

C language me kisi block ya function me declare sabhi variables by default automatic variable hote hai. Ham auto keyword ka use karke bhi kisi bhi variable ko automatic variable bana sakte hai.

Example ke liye:-

External Variable

Ham c language ki header file ka use karke external variable bhi create kar sakte hai. External keyword ko declare karne ke liye hame extern keyword ka use karna padta hai. External variable bhi global variable he hote hai.

For example-

Note:- Aap header file ke bare me next lecture me padege. To aap yhan abhi header file ka naam padkar confuse mat hona.

Related Lecture

Dear Students, main aasha karta hun ki aapko Variables In C Ka Lecture padh kar samjh me aa gaya hoga. Ki variables kya hote hai. Yadi aapako (Variables In C) ke Lecture se related koi bhi problem hai to aap hume comment karke puch skte hai.

Share This Post On

About Author

Thakur Aman Singh

Hey, I am Aman Singh Tomar from Taj City Agra. Through This Blog I want to share my Knowledge with all of you. Read More >>

Leave a Reply

Your email address will not be published. Required fields are marked *