Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 array total
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
scorpion1087




PostPosted: Tue Oct 14, 2003 5:26 pm   Post subject: array total

how do you add the numbers in an array together?

(im trying to find the average)
Sponsor
Sponsor
Sponsor
sponsor
Blade




PostPosted: Tue Oct 14, 2003 5:49 pm   Post subject: (No subject)

you need a variable to keep the total of the array, then you add each element in the array to the total

code:
var total:int:=0
var nums:array 1..10 of int

%initialize your array here

for i:1..10
  total += nums(i)
end for


glad to see you finally posted...
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: