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

Username:   Password: 
 RegisterRegister   
 getting 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: getting 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
Mazer




PostPosted: Thu Nov 18, 2004 8:32 am   Post subject: (No subject)

Please be careful before you post. Alot of these should have gone in Turing Source Code.
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  [ 2 Posts ]
Jump to:   


Style:  
Search: