sum=0
count=0
loop {
print " enter value"
read value
if value=0 then exit loop
sum += value
count += 1
}
if count=0 then print "no values entered"
else {
avg = sum/count
print "the average of ", count, " values is ", avg
}
In this exercise you will create a program that computes the average of a collection
of values entered by the user. The user will enter 0 as a sentinel value to indicate
that no further values will be provided. Your program should display an appropriate
error message if the first value entered by the user is 0.
1 answer