Assignment operators in c

Assignment operators in c

The values stored in any variable or in any operand using assignment operator. The operand on the left hand side should be variable where value will be assigned, while on the right hand side the operand can any variable, constant or expression. so the value of right hand side will assign to the left hand side operand. here in the below some examples of assignment expressions –

a=9                /*9 is assign to a*/
b=10               /* 10 is assign to b*/
c=a+b-1               /* value of a+b-1 is assigned to c*/
c=b               /* value of b is assigned to c*/

We can have multiple assignment operators also for example–

a=b=c=50

here in the above example all the three variables a,b,c will be assign 50. and the value of the complete expression will be 50

There are some examples are given below of assignment operators-

a=a+9                can be written as a+=9        /*a+9 is assign to a*/
b=10*b               can be written as b*=10        /* b*10 is assign to b*/
c=c/10               can be written as c/=10        /* value of c/10 is assigned to c*/
c=c-5               can be written as c-=5        /* value of c-5 is assigned to c*/