Hey guys,

First post here but i've been a lurker for the past few days. I'm just fiddling with some C# exercises since I decided to try my hand at programming the other day. Please excuse me for being a complete rookie!

So...Pseudocode. As far as I understand its a seperate language that sort of helps programmers translate into code.

The pseudocode exercise that I've been told to do (know-it-all friend) is asking me to create a system that asks questions that respond on a scale out of 10. A question is asked and a response entered between 0 and 10. This is supposed to happen up to 20 times until finished or until the user enters a number over 10 or below 0. Also it has to measure the average, max, min and total response.

My query is... How do I go about initialising the variables and ultimately getting i to display the average and so on...

Any help is appreciated :),
Bec

Well, actually pseudocode doesn't have any fixed syntax and I think everyone writes it on one's own way, but usually its style is similar to Pascal (in my opinion). The most important thing is to make it understandable ;) I would ride something like that:

min = 10
max = 0
i = 1
total = 0
for i=1 to 20 
do
    print "Enter a number between 0 and 10";
    read response 
    if (response>20 or response<0)
        break
    if (response<min)
        min = response
    if (response>max)
        max = response
    total = total + response
end

average = total / i

print min
print max
print average
print average
Comments
Thanks very much
This article has been dead for over six months. Start a new discussion instead.