1.

What are pre-increment and post-increment operators? Give examples.

Answer»

The pre-increment operator is a unary operator and is used to increment the value of variable before using in the expression i.e. value is first incremented and then used in the expression.

Example:

Y = 5;

cout<< ++Y;

output: 6.

The post-increment operators is also unary operator and is used to increment the value of variable after the use of expression.

For example;

Y=5;

cout<< Y++;

output: 5. 



Discussion

No Comment Found

Related InterviewSolutions