Basic Programming Concepts In Desi Way - Part 3 (Variables)

Variables:

Chalain aaj hum mil kar kuch kapray(clothes) dhotay hain. Nahi nahin programming nay mujhe pagal nahi kiya aur hum Variables hi sheekhain gay lekin kapray dhoonay ke style mein.

Imagine karain aaj humari kapray dhonay ki bari hai. Aur upar se zulm yeh ke humein sirf apne nahi balke puray ghar ke kapre dhonay hain, Sach mein sabke, Abu, Ammi aur Badi Behen. Wowww!

Iske ilawa inn sabke kapre dhonay ka tariqa bhi aik dosray se farq hai. 

Abu: (Abu ke kapray iss tarteeb se dhonay hain)
  1) Kapre garam pani mein detergent ke saath 15 mins tak rakhein
  2) Washing Machine mein dhoyein
  3) Dryer mein sokhayein

Ammi:
  1) Kapre garam pani mein detergent ke saath 15 mins tak rakhein
  2) Haath se dhoyein
  3) Beghair dryer ke bahar sokhayein ke liye daal dain

Badi behen:
  1) Kapre Washing Machine mein dhoyein
  2) Dryer mein sokhayein

Haan aap log sahi samjhay mere ghar walay kuch zyada hi different hain.

Ab imagine karain sab logon nay apne ganday kapre laa kar aik jagah daal diye. Iski wajah se mera kaam buhat hi mushkil ho jaye ga kyunke different tareeqay se kapre dhonay ke liye mujhe pehle sabke kapre alag karne hongay.

Bilkul issi tarah programming mein sara Data (kapray) aik jagah rakhain se hum computer ko properly nahi bata sakte ke kaunse Data pe kya kaam karna hai aur kaisay karna hai.

Data koi bhi information ho sakti hai. Jaisay ke apka naam(Farjad), umar(32), ghar ka pata(Islamabad) yeh sab Data hai. Ab sochon main issay aik jagah rakh don, "Farjad32Islamabad", toh mere liye computer ko samjhana mushkil ho jaye ga ke mera naam kaunsa hai aur umar kaunsi.

Iss maslay ko solve karne ke liye hum baltiyaan istamaal karein gay. Yaar Kapron ko nahi bholain. Kapron ko alag karne ke liye hum 3 baltiyaan lay laitay hain aur ghar walon se kehte hain ke woh apne kapray alag baltiyon mein daalain gay. Aur har balti pe hum ghar ke fard ka naam likh dain gay takay pehchainay mein asani ho.

Ab hum asani say kapray dho sakte hain.

  • Pehle Abu aur Ammi ki balti ke kapre garam pani mein daalein, 
  • kitni dair Badi Behen ki balti ke kapron ko washing machine mein dhoya, 
  • Phir Abu ki balti ke kapron ko washing machine mein daala 
  • aur Behen ke kapray dryer mein daal diye. 
  • Itnay mein Ammi ke kapray haath se dho kar bahar daal diye. 
  • Phir Behen ke kapre dryer se nikal liye 
  • aur Abu ke kapre dryer mein daal diye. 
Bas yehi sab hum programming mein bhi karte hain, Data ko aik jagah se liye ussay use kiya phir dosri jagah daal diya.

Example (PHP Programming Language)

Main apne naam aur umar wali example laita hn. Programming ke hisaab se hum baltiyon ki jagah Variables use karain gay Data ko separate aur store karne ke liye.

$naam = "Farjad";
$umar = 32;
$pata = "Islamabad";

PHP Language mein Variable ka naam liknay ke pehle ($) ka nishaan lagana zarori hai. Yeh PHP ka Syntax hai. Agar apko Syntax ka matlab nahi pata toh please iss series ka Part 2 parhein.  

Hum keh sakte hain Variable aik balti hai aur Variable ka naam ussay dosre variables se mukhtalif karne aur identify karne ke liye hai.

Jaise ke,

             $AmmiKiBalti = "Kapray";
             $AbuKiBalti;
             $BehenKiBalti;


Apne note kiya hoga maine $AbuKiBalti aur $BehenKiBalti ke variables ke aagay kuch nahi likha. Asal mein yeh humari marzi hoti hai ke hum Variable mein koi Data daalna chahein ya nahi. Abu aur Behen ke variables humne bana liye hain lekin abhi woh khali hain. Aur Ammi ke variable mein humne Kapray daal diye hain.

Ab programming mein bhi humare liye asan ho gaya hai ke jab hum jo bhi variable istamal karna chahein toh humein sirf variable ka naam likha hai aur uske undar ka Data wahan available ho jaye ga.

Maslan,

Main chahta hn computer screen pe mere naam likha huwa nazar aaye. Toh mein likhon ga,

echo $naam;

Jaise hi computer yeh line dekhay ga toh woh check karne lagay ga ke $naam variable mein kaunsa Data hai aur ussay "Farjad" mil jaye ga. Iske saath hi woh lafz "Farjad" screen pe dikhana shuru kar day ga.

Umeed hai aap logon ko Variables ka concept thora clear huwa hoga. Agar nahi huwa toh koi baat nahi, "Main hoon na".




Comments

Popular posts from this blog

Basic Programming Concepts In Desi Way - Part 5 (Keywords)

Basic Programming Concepts In Desi Way - Part 1

Basic Programming Concepts In Desi Way - Part 4 (Data Types)