Quote:
value of c should have been assigned as 33 but instead it's just 30
30 is, the correct result for this code!
Your code means:
void sum(int a,int b,int &c)
{
c = a + b; a = a + 1;
b = b + 1;
}
which is post increment.
If you use pre increment, the correct result is 32:
void sum(int a,int b,int &c)
{
a = a + 1;
b = b + 1;
c = a + b; }