|
-
Jan 5th, 2003, 03:11 PM
#4
Thread Starter
Frenzied Member
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;
}
result = 12206
I was trying to figure out why in the for loop isn't n<5 instead n<=5 because there are 5 elements in the array.
I am thinking that the computer sees billy[n] as billy[0], billy[1], billy[2] . . .etc. when the loop is done. Am I right?
Last edited by aewarnick; Jan 5th, 2003 at 03:16 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|