15,348,829 members
See more:
I have confusion with i++ and ++i .
Posted

## Solution 2

If you are not sure about expressions then you should spend time studying the documentation[^]. It is important to get these concepts fixed in your mind.

## Solution 1

First case
C++
```int i = 10;
int j = i++;```

After execution value of i would be 11 and value of j would be 10.
As this operator is POSTincrement , increament will be done AFTER the assignement.

Second case
C++
```int i = 10;
int j = ++i;```

After execution value of i would be 11 and value of j would be 11.
As this operator is PREincrement , increament will be done BEFORE the assignement.
v2
Nisarg S Shah 19-Jul-12 5:12am

I think that "i would be 11 and value of j would be 10." and "i would be 11 and value of j would be 11." should be highlighted along with AFTER and BEFORE.
PrafullaVedante 20-Jul-12 2:54am

Done :)

## Solution 3

hi

once lookat this

C#
```string[] items = {"a","b","c","d"};
int i = 0;
foreach (string item in items)
{
Console.WriteLine(++i);
}
Console.WriteLine("");

i = 0;
foreach (string item in items)
{
Console.WriteLine(i++);
}```

output will be

C#
```1
2
3
4

0
1
2
3```

i hope it helps you...

Thanks&&Regards
Sandeep