3. Differentiate between prefix and postfix increment operators
Answers
hi friend,
here is your answer
please follow me
Answer:
Postfix increment operator means the expression is evaluated first using the original value of the variable and then the variable is incremented(increased).Prefix decrement operator means the variable is decremented first and then the expression is evaluated using the new value of the variable.
In the prefix version (i.e., ++i), the value of i is incremented, and the value of the expression is the new value of i. So basically it first increments then assigns a value to the expression.
In the postfix version (i.e., i++), the value of i is incremented, however, the {value|the worth} of the expression is that the original value of i. So basically it first assigns a value to expression and then increments the variable.
example given
hope it helps you and you understood
if helps please follow me
Explanation:
Programming languages like C/C++/Java have increment and decrement operators. These are very useful and common operators.
Increment Operators: The increment operator is used to increment the value of a variable in an expression. In the Pre-Increment, value is first incremented and then used inside the expression. Whereas in the Post-Increment, value is first used inside the expression and then incremented.
Syntax:
Decrement Operators: The decrement operator is used to decrement the value of a variable in an expression. In the Pre-Decrement, value is first decremented and then used inside the expression. Whereas in the Post-Decrement, value is first used inside the expression and then decremented.