When I tried to find the behavior of increment operators I got this result which I ended up wit two questions. Here is the code and output.
#include <iostream>
using namespace std;
int main(){
int arr[4] ;
int x =0;
cout << arr[0] <<"_"<< arr[1]<<"_"<<arr[2]<<"_"<<arr[3]<<"**"<< x<< endl;
arr[x] = 10;
cout << arr[0] <<"_"<< arr[1]<<"_"<<arr[2]<<"_"<<arr[3]<<"**"<< x<< endl;
arr[x++] = 20;
cout << arr[0] <<"_"<< arr[1]<<"_"<<arr[2]<<"_"<<arr[3]<<"**"<< x<< endl;
arr[++x] = 30;
cout << arr[0] <<"_"<< arr[1]<<"_"<<arr[2]<<"_"<<arr[3]<<"**"<< x<< endl;
arr[x] = arr[x--] + arr[--x];
cout << arr[0] <<"_"<< arr[1]<<"_"<<arr[2]<<"_"<<arr[3]<<"**"<< x<< endl;
return 0;
}
the result was
-1_-1_4254245_0**0
10_-1_4254245_0**0
20_-1_4254245_0**1
20_-1_30_0**2
50_-1_30_0**0
- Q:1 what are those default values of the array?
- Q:2 how 50 came as the vale of the zeroth position of the array ?