Increment and Decrement Operators:
++ and - -The Operator + + adds 1 to the operand while -- subtracts 1, Both are unary operators
Eg :
++x or x ++ == > x+=1 == > x=x+1
-- x or x- - == > x-=1 == > x=x-1
A Profix operator first adds 1 to the operand and then the result is assigned to the variable on left. A postfix operator first assigns the value to the variable on the left and the increments the operand.
Eg:
1) m = 5; 2). m = 5
y = ++m; y = m++
O/P:
m =6, y=6 m=6, y=5
0 comments:
Post a Comment