pseudocode = teh gayz0r (1 Viewer)

r.haidar

not crusin til schoolies!
Joined
Oct 19, 2004
Messages
196
Location
a
Gender
Male
HSC
2005
MY.STUPID.UNI.ASSIGNMENT said:
Write an algorith that reads integers stored into an array data[1...n] and returns the average value of the integers.
this is what i said:

BEGIN ArrayAverage
DEFINE data[1…n]​
SET count TO 1​
WHILE count<= n​
GET data[count]​
SET count TO count + 1​
ENDWHILE​
SET sum TO data[count]
SET count TO count + 1
average = sum/n
Return Average​
END ArrayAverage


does mine do it? this is for 1% of my friggen grade but its drivin me nuts lol
 
Last edited:

DeathB4Life

Bánned
Joined
Feb 4, 2006
Messages
590
Gender
Male
HSC
2006
try:


BEGIN ArrayAverage
DEFINE data[1…n]​
SET count TO 1

SET sum TO 0
WHILE count<= n​
SET sum to sum + data[count]

SET count TO count + 1

ENDWHILE

Average = sum/n .... or: Average = sum/[count-1]
Return Average​
END ArrayAverage



not sure if you need that GET data[count] in there.
 

withoutaface

Premium Member
Joined
Jul 14, 2004
Messages
15,098
Gender
Male
HSC
2004
Write the fucking thing in C and add a printf message telling them to go get raped by a camel for demeaning a university course to such a level.
 

r.haidar

not crusin til schoolies!
Joined
Oct 19, 2004
Messages
196
Location
a
Gender
Male
HSC
2005
withoutaface said:
Write the fucking thing in C and add a printf message telling them to go get raped by a camel for demeaning a university course to such a level.
lol i concur. thanks for the help death!
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top