Computer Science, asked by sadanandjha982, 9 months ago

Differences between pre increment and post increment.

Answers

Answered by DrNykterstein
3

Pre-increment

In this, the value is incremented first and then used.

Example:

int a = 5;

cout << ++a;

Output: 6

Post-increment

Value is first used and then incremented.

Example:

int a = 2;

cout << a++;

Output: 2

Answered by Anonymous
2

pre increment :- In simple words pre increment means , "change than use".

ex:-

a=4;

cout<<++a; // output = 5

cout<<a; // output = 5

post increment:- In simple words post increment means ,"use than change".

ex:-

a=4;

cout<<a++; //output = 4

cout<<a; // output = 5

Similar questions