Advertisement
Guest User

Untitled

a guest
Dec 14th, 2010
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.36 KB | None | 0 0
  1. int i, x, a[2];
  2.  
  3. void q(int b)
  4. {
  5.   // here you have: a = [1, 2], and b = 1 from the call
  6.  
  7.   a[0] = 2; // now: a = [2, 2]
  8.  
  9.   i = 1;
  10.  
  11.   x = b+a[i]; // x = 1 + a[1] = 1 + 2 = 3
  12.  
  13.   b = a[0]; // b = 2 but forgot because it's local to the function
  14. }
  15.  
  16. void main()
  17. {
  18.   i = 0;
  19.   a[0] = 1;
  20.   a[1] = 2;
  21.  
  22.   // a[i] = a[0] = 1, so: q(1)
  23.   q(a[i]);
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement