what does += mean??

help i cann't make heads nor tales of this script it was an example in the arrays part of the tutorial
i would really apreciate it if someone could explain it in detail
thanxx

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// arrays example
#include <iostream>
using namespace std;

int billy [] = {16, 2, 77, 40, 12071};
int n, result=0,d;

int main ()
{
  for ( n=0 ; n<5 ; n++ )
  {
    result += billy[n];
  }
  cout << result;
  cin>>d;
}
Last edited on
result += billy[n];
is same as
result = result + billy[n];
thanx that helps me with +=
but i still cann't understand how result ends up with the value 12206
i need a more explanatory replay.i'm really new to c++.
thanx though.
Result started at 0. The result(new value) = result(old value which is 0) + 16. So now result equals 16. The next time result(new value) = result(old value which is 16) + 2 equals 18 and so on.
thanks a million i posted that question a few days ago and since i learned
so much more but still in all ...thanks
Topic archived. No new replies allowed.