Assignment Operator:
The
assignment operator ( = ) is the most commonly used binary operator in C. It
evaluates the operand on right hand side and then assigns the resulting value
to a variable on the left-hand side. The right operand can be a variable,
constant, function call or expression. The general form of representing
assignment operator is:
variable
= expression/ constant/ function call
In
addition, C has a set of ‘shorthand’ assignment operators of the form. Where v
is variable, exp is an expression and op is a C binary arithmetic operator. The
operator op = is known as the shorthand assignment operator.
The
assignment statement
v op= exp;
is
equivalent to
v = v op ( exp );
The
use of shorthand assignment operators has three advantages:
1.
What appears on the left-hand side need not be repeated and
therefore it becomes easier to write.
2.
The statement is more concise and easier to read.
3.
The statement is more efficient.
Post a Comment