0
Please explain me Sir or Madam. I'm confusing with this.
3 odpowiedzi
+ 4
#include <iostream>
using namespace std;
int main() {
int x = 0;// store zero in x
int a[]= {3,4};// create an array
a[x]= ++x;
/*
First, x is incremented by 1, so the value of x becomes 1. Then modify value of second item in a[], why the second item? Because x has been incremented prior to assignment as an index of a[]. To verify this modify the next line to
cout << a[1];
*/
cout << a[0];
return 0;
}
+ 3
Thank you all, Sirs.
+ 1
int x = 0;
a[x] = ++x;
------------------
After ++x you've got x = 1 and:
a[1] = 1.