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

Username:   Password: 
 RegisterRegister   
 using an array to get an average
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
zomg




PostPosted: Thu Nov 18, 2004 8:20 am   Post subject: using an array to get an average

Hi this is a basic "finding an average of 5 numbers" program

code:

var mark :int
var sum :int :=0
put"Enter Marks."
for count :1..5
    put count
    get mark
    sum:=sum+mark
end for
put"Average is ", round (sum/5)


you can change how many numbers u want to average by

code:

for count :1..6


or get the end user to input how many numbers he wants to average u do this:

code:

var x : int
var mark :int
var sum :int :=0
put"how many numbers would u like to average?"
get x
put"Enter Marks."
for count :1..x
    put count
    get mark
    sum:=sum+mark
end for
put"Average is ", round (sum/x)


[/quote]
Sponsor
Sponsor
Sponsor
sponsor
Andy




PostPosted: Thu Nov 18, 2004 10:29 am   Post subject: (No subject)

question.. do you enjoy posting code that everyone on the site noes how to write? plz only post useful codes that is at least semi difficult and requires and actually requires thinking and problem solving so others can learn from it
zomg




PostPosted: Thu Nov 18, 2004 12:03 pm   Post subject: (No subject)

jeez i thought somebody might not kno how to do it, sorry Confused

o well whatever

and u might want to delete my other post thats exactl the same
im not shure how it happened but its called"find an average"
just thought i'd tell ya
Andy




PostPosted: Thu Nov 18, 2004 3:41 pm   Post subject: (No subject)

nope cant.. dan wont give me powers in the turing sections.. hes afraid i'll scare too many ppl..
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: