What is the importance of post increment and pre increment in C++?

154 views

What is the importance of post increment and pre increment in C++?

In: 7

7 Answers

Anonymous 0 Comments

Basically both mean add 1 to the number but one first does something with the number and then adds one and the other first adds one and then does the thin with it.

If x has the value of 2 both x++ and ++x will result in x having the value of 3.

However if you use this not just by itself but while doing something else like

A = ++x;

And

A = x++;

will result in x being 3 both times but in he first example A is 2 and in the second A is 3.

You are viewing 1 out of 7 answers, click here to view all answers.