0

Please explain me Sir or Madam. I'm confusing with this.

https://code.sololearn.com/cxklGh60CxXz/?ref=app

8th Jul 2017, 6:57 AM
Phyoe Min Thant
Phyoe Min Thant - avatar
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; }
8th Jul 2017, 7:36 AM
Ipang
+ 3
Thank you all, Sirs.
8th Jul 2017, 11:23 PM
Phyoe Min Thant
Phyoe Min Thant - avatar
+ 1
int x = 0; a[x] = ++x; ------------------ After ++x you've got x = 1 and: a[1] = 1.
8th Jul 2017, 7:32 AM
Chomitch
Chomitch - avatar