You are on page 1of 2

Working together, do this now:

Design a program (pseudocode) which accepts 100 numbers and then


a) Displays them back in reverse order and
b) Gives the average of all 100 numbers

Pseudocode : Numbers

// this program will accept 100 numbers


display in reverse order, give the user average.

Declarations
Variables
values[100] - data type real
New_tot, Tot - data type real

Process
Tot ← 0.0
FOR count ← 0 to 99 DO
Display “Enter a number.”
Read numvalues[count]
Tot← Tot+numvalues[count]
ENDFOR

Call function reverse (values[100])


Call function avg(Tot)
Stop

Function reverse(value[])
//displays numbers entered in reverse order

Declarations
Parameters
values[ ] - data type real // value parameter
Variables
count - data type integer

Process
FOR count← 100 to 0 Step -1 DO
Display values[count]
Endfor
Stop
Function avg(tot)

// calculate and display the average of 100 numbers

Declarations

Parameters
Tot - data type real //variable parameter

Variables
avg - data type

Process
avg← Tot/100
Display “The average of these numbers is:” ,avg
Stop

You might also like