Assignment Operators


Assignment Operators

The Assignment Operator evaluates an expression on the right of the expression and substitutes it to the value or variable on the left of the expression. 
Syntax:  Variable = Expression;
Eg:-  x = a + b
Here the value of a + b is evaluated and substituted to the variable x. 
shorthand assignment operators
var oper = exp; 
Here var is a variable, exp is an expression and oper is a C binary arithmetic operator. The operator oper = is known as shorthand assignment operator 
Eg:- x + = 1 is same as x = x + 1
The commonly used shorthand assignment operators are as follows 


Assignment Operator
Shorthand Operator
a=a+1
a+=1
a=a-1
a=a-1
a=a*(p+1)
a*=(p+1)
a=a/(p+1)
a/=(p+1)
a=a%(p+1)
a%=(p+1)


No comments:

Post a Comment