tutorial question

i can't understand this code??

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;

int main ()
{
  for ( n=0 ; n<5 ; n++ )
  {
    result += billy[n];
  }
  cout << result;
  return 0;
}
Which part don't you understand?

Have you looked at any tutorials? There is a good one on this site + lots of reference info as well.

HTH
n- is a stepper variable
result is a most recent holder or sumator variable
billy is an intiger array and it holds variables as written
in main result gets numbers from array and stores it

billy [0] = 16
so result at that step is : result =0+16
at next step billy [1] = 2
so result after that is previous result =16 +2
next step where billy [2] = 77
so result = 18+77
and so on

whas this helpfull at all???
Last edited on
now i have it
my English is bad and google doesn't support c++ expressions so i didn't understand it
thx alot
Topic archived. No new replies allowed.