Computer Science Canada

getting an average

Author:  zomg [ 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]

Author:  Mazer [ Thu Nov 18, 2004 8:32 am ]
Post subject: 

Please be careful before you post. Alot of these should have gone in Turing Source Code.


: