![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 | |
|
Newbie
Join Date: Jun 2006
Location: Bath Room
Posts: 11
Rep Power: 0
![]() |
Help with array
Can you guys tell me why a have the result of 12206, I thought that the result will be the values o billy(16, 2, 77, 40, and 12071)
Quote:
|
|
|
|
|
|
|
#2 |
|
PFO Founder
![]() ![]() |
What you are doing is adding the values of billy(16, 2, 77, 40, and 12071) and that equals 12206, you are getting the results that your program is suppose to give you if you are getting 12206
__________________
BIG K aka Kyle Programming Forums Kyle K Online Please do not PM or email me programming questions. Post them in the forums instead. |
|
|
|
|
|
#3 |
|
The Supreme Ruler
![]() Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6
![]() |
for ( n=0 ; n<5 ; n++ )
{
result += billy[n];
}What this part is doing is: result = result + billy[n]; If result is originally 0, then after the first iteration of the loop result will be: 0 + billy[0], or 0 + 16. After the second iteration it will be: result = result + billy[1] or result = 16 + 2 because result retains the value was previously assigned to it, which in this case was 16. It repeats that process over and over until it adds everything in the array up.
__________________
"Every gun that is made, every warship launched, every rocket signifies, in the final sense, a theft from those who hunger and are not fed, from those who are cold and are not clothed. The world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children." - Dwight D. Eisenhower |
|
|
|
|
|
#4 |
|
Newbie
Join Date: Jun 2006
Location: Bath Room
Posts: 11
Rep Power: 0
![]() |
huuuu, got it, thank you guys, you are the best.
|
|
|
|
|
|
#5 |
|
Newbie
Join Date: Jun 2006
Location: texas
Posts: 22
Rep Power: 0
![]() |
indeed.
|
|
|
|
|
|
#6 | |
|
Battle Programmer
Join Date: Feb 2006
Location: Bellevue, WA, USA
Posts: 773
Rep Power: 3
![]() |
indeedydo. Please keep your posts contributory to the threads.
Oh, and change the avatar please. Quote:
|
|
|
|
|
|
|
#7 |
|
Newbie
Join Date: May 2006
Posts: 19
Rep Power: 0
![]() |
|
|
|
|
|
|
#8 |
|
Hobbyist Programmer
Join Date: Oct 2005
Location: Ohio
Posts: 177
Rep Power: 0
![]() |
What was the point of this thread?
|
|
|
|
|
|
#9 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
The point of the thread was that Edgar had a problem understanding some things about arrays. The point of a number of the responses (including yours) is anyone's guess. The point of my response (similar to Jim's) is making a point about points in response to your response. I actually thought I might puke in my shirtpocket to see a link reproducing the OP's code.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|