Billy isnt making sense (tutorial question, arrays)

Somehow, this code isnt making sense to me:

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;
}


How is the int "n" (line 10) supposed to be equal to 0 at initialization?
Thanks!
it is assigning 0 to n NOT testing for equality .

= is assignment.
== is equality test.
Last edited on
Ohhhhh I see, thanks so much :D
Topic archived. No new replies allowed.