Posted: 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
Andy
Posted: 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
Posted: Thu Nov 18, 2004 12:03 pm Post subject: (No subject)
jeez i thought somebody might not kno how to do it, sorry
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
Posted: 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..