Computer Science, asked by RubySinha1, 1 year ago

How are the variables assigned a value? Help with the help of an example.

Answers

Answered by garywalter1221
2

for ex.


int  a=2;


ok

see 'a' is a variable and 2 is the no. which is assigned to 'a'.


hota kya hai isme jb bhi hm kisi no. ko kisi variable me assign krte hai tb hm hamesa equals to(=) operator ka use krte hai . No. hamesa right to left ki taraf assign hota hai. Program ke execution mtlb jb aap program run krte hai to  Variable ki value pure program me khi pr bhi change ho skti hai wo aap pr depend hota hai ki aap value ko change krna chate ho ya nhi.


for ex.


int 2=a;   (wrong)


int a=2; (right)




ab ata ha (==) operator

for ex

a==2;


iska mtlb hua ki 'a' ki value 2 hai yeh pure program me change nhi ho skti jb tk aap apne program ke source code me change na kre.

yeh adhiktar conditional statements me use kiya jata hai

for ex. if,if-else etc.



I hope this will help u

Similar questions