Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Array question

 
Brusse James
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Let's say I want to input (10) values into an array, and have them averaged, ok. Should I read each number in separately and them set those numbers to an array address? And is there an '.average' method? How can I make this quick and easy to follow (mostly for myself). Thanks in advance.
 
James Chegwidden
Author
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use a for loop to read in numbers, use a var like sum to sum the values as you read them in and then finally divide by the number of elements.
There is no .average method. There is .length- it is not a method.
 
Brusse James
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
James,
Thanks for the help. I'll give it a shot and get back to you with any further questions.
Brusse James
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic