GURU NANAK DEV CO-ED POLYTECHNIC

GURU NANAK DEV CO-ED POLYTECHNIC
MAIN BULIDING

Friday, 30 September 2011

C Programming- Assignment Operators


Assignment operators are operators, which are used to simplify the coding of certain type of assignment statement. The syntax is
                                    variable operator = expression
where,
            variable            -           valid user defined name
operator           -           + - * / %
expression        -           constant (s)or a variable(s) or operator(s)

Example

            The table given below lists the operators with example.
Operator
Meaning
+=
value of LHS variable will be added to the RHS value and is assigned to LHS variable.
-=
RHS value will be subtracted from LHS variable and is assigned to LHS variable.
*=
value of LHS variable will be multiplied by the RHS value and is assigned to LHS variable.
/=
value of LHS variable will be divided by the RHS value and is assigned to LHS variable.
%=
value of LHS variable will be divided by RHS value and the remainder will be stored in the LHS variable.