What is the increment operator?

Are you preparing for IT certification? With practice questions, study notes, interactive quizzes, tips and technical articles, uCertify PrepKits ensure that you get a solid grasp of core technical concepts to ace your certification exam in first attempt.

What is the increment operator?

Rating:

The increment operator is a unary operator that increases the value of its operand by one. For example, the expression a++ increases the value of a by 1. This statement is equivalent to the expression a = a + 1.

The increment operator can be used in either of the two forms given below:

  1. Prefix form: In the prefix form, it appears before the operand. For example, ++a;

  2. Postfix form: In the postfix form, it appears after the operand. For example, a++;
In both forms given here, the increment operator increases the value of the operand (a) by 1. However, when these two expressions are a part of a larger expression, they create a significant difference in the value of the expression. For example,

b = ++a;
b = a++;

In the first statement, due to the pre-increment operator, the value of operand a is first incremented by 1 and then this new value of a is assigned to variable b. On the other hand, in the second statement, due to the post-increment operator, the initial value of variable a is first assigned to variable b and then the value of a is incremented by 1.


Rating:



Other articles

Click here to Article home

 
uCertify.com | Our Company | Articles | Privacy | Security | Contact Us | News and Press Release | uCertify India
MCSE: MCSA, MCTS, MCITP    JAVA Certification: SCJP, SCWCD Cisco Certification: CCNA, CCENT, A+, Network+, Security+
Oracle Certification: OCP 9i, OCP 10g, OCA 9i, OCA 10g CIW foundation    EC-212-32    CISSP    Photoshop ACE    Adobe Flash ACE
© 2008 uCertify.com. All rights reserved. All trademarks are the property of their respective owners.