# Pseudocode Problem Help



## big-tony (Jul 26, 2007)

I am wondering how I could do the following question, but in Pseudocode only.

Input a list of people's ages from the user (terminated by 0) and find the average age.


----------



## JimmySeal (Sep 25, 2007)

You've got to put in the first bit of effort. Why don't you make a list of steps (some will need to be repeated) that you would take if you were doing this task by hand, and we'll help you make it more pseudocode-like.


----------



## -Fabez- (Jul 28, 2008)

Pseudocode is essentially a series of steps that you will take. So you would basically write down the steps you would take to solve your problem. This link might help you http://en.wikipedia.org/wiki/Pseudocode


----------



## big-tony (Jul 26, 2007)

This is what i had so far, dunno where to go from here: 

Declare avg_age as real
Write"This program will display"
Write "the average age of a group of people"
Call avg age calc module
write"enter a group of peoples ages"
Input ages
Write "how many people are inputed?"
Input ppl_amount


----------



## lotuseclat79 (Sep 12, 2003)

big-tony said:


> I am wondering how I could do the following question, but in Pseudocode only.
> 
> Input a list of people's ages from the user (terminated by 0) and find the average age.


First, you need to keep the sum of the ages, and a count of how many people's ages were input so that you can compute the average = sum divided by number of people (ages) input.

For simplicily, you can keep a running average output by constructing a loop until the last value '0' is input.

Definitions and initialization of sum and number of people and average age (note: 2 are integers, one real).
read age
While (last age not input)
compute sum
add increment to number of people
read age
end while loop
compute average age
output average age, number of people
end program

-- Tom


----------



## JimmySeal (Sep 25, 2007)

big-tony said:


> Input ages
> Write "how many people are inputed?"
> Input ppl_amount


Try to explain the input ages part in a bit more detail, and show steps for how you will compute the average once you have all the ages.
You shouldn't need to query for the number of people since that can be surmised by the number of ages that were input.


----------

