Can someone walk me through the example below and how it comes to 12206? I'm having trouble following.
Thank you,
-Ari
// 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;
}
I may have just figured it out... first time through the loop n=0, so billy =16... result becomes 16...
Second time through n=1, so result becomes 16+2=18... and so on... +77... +40... +12071... Yup, there's the 12206. Haha, thanks for making me look at it closer. :)