Hi I am trying to run the post fix and pre fix operation in C++.
The code which I tried is given below.
#include <iostream>
using namespace std;
int main()
{
int a =0;
cout << ++a + ++a + ++a << endl; // 7
a =0;
cout << ++a + ++a + a++ << endl; // 6
a=0;
cout << ++a + a++ + ++a << endl; // 4
a=0;
cout << ++a + a++ + a++ << endl; // 3
a=0;
cout << a++ + ++a + ++a << endl; // 4
a=0;
cout << a++ + ++a + a++ << endl; // 3
a=0;
cout << a++ + a++ + ++a << endl; // 1
a=0;
cout << a++ + a++ + a++ << endl; // 0
}
Output ===>
7
6
4
3
4
3
1
0
I am not able to understand the way the value is calculated.
One or two example will be really helpful.
Thanks