Explanation of Increment(++) and Decrement(--) Operator
Can anyone explain the concept of Increment(++) and Decrement(--) operator?
Answers
Answered by
1
Increment and decrement operators are used to add or subtract 1 from the current value of oprand.
++ increment
-- decrement
Increment and Decrement operators can be prefix or postfix. In the prefix style the value of oprand is changed before the result of expression and in the postfix style the variable is modified after result.
For example.
a = 9;
b = a++ + 5; /* a=10 b=14 */
a = 3;
b = ++a + 6; /* a=10 b=15 */
++ increment
-- decrement
Increment and Decrement operators can be prefix or postfix. In the prefix style the value of oprand is changed before the result of expression and in the postfix style the variable is modified after result.
For example.
a = 9;
b = a++ + 5; /* a=10 b=14 */
a = 3;
b = ++a + 6; /* a=10 b=15 */
Answered by
0
Increment operator:- The operator which increase the value of a variable by one called increment operator.
Ex:-
a=1;
++a=2
Decrement operator:-The operator which decrease the value of a variable by one called decrement operator.
Ex:-
a=1;
--a=0
Similar questions