If ages are 10 20 30 what will be the average Si la edade Av
If ages are 10, 20, 30, what will be the average?
Si la edade AverageAge Sum = 0 Initializes sum and counter to 0 Counter = 0 Enter Age (Primer Read) Enters first age While False Age = 0 is Age0a value to stop the loop True Sum = Sum Accumulates the ages + Age Counter Counter t 1 Counts the numbor of ages Enters the next age Enter Average = Calculates Solution
If ages are entered as 10 20 30 , and to stop loop 0 is entered,
then average = 20
Explanation- each time age is entered,
sum is increased by age counter is increased by1.
So initially sum=0, counter=0
Enter age 10, sum=sum+10=10, counter=counter+1=1
Enter age 20, sum=sum+20=30, counter=countrt+1=2
Enter age 30, sum=sum+10=60, counter=countrt+1=3
Enter age 0, condition false loop stops
Then average=sum/counter=60/3=20
