You are on page 1of 3

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 : NumbersReverse

DECLARATIONS
Constants
Max = 99
Tot_num = 100

Variables
Nums[Tot_num], count, sum - datatype - integer
avg - datatype - real

PROCESS
Sum ← 0
FOR count ← 0 to max do
Display “ Enter a number”
Read nums[count]
Sum ← Sum + Nums[count]
ENDFOR

FOR count ← max to 0 step -1 do


Display nums[count]
ENDFOR

Avg ← Sum/Tot_num
Display “The average is”, Avg
STOP
Array activity from worksheet:

Pseudocode:Numbers
// to obtain and store 30 numbers find the total, average and
// display them in reverse order. Then to replace the values for
//the 10th 20th and 30th elements And display the new total. To
//find the average of the contents and display the amount of
//elements larger than it Written by Group B 19/11/2020

DECLARATIONS

Constants
amtnum = 30
maxnum = 29

Variables
nums[30], total, k, sum - data type integer
avg - data type real
PROCESS

total ← 0
sum← 0
For k ← 0 to maxnum Do
Display “ Enter a number”
Read nums[k]
Total ← total + nums[k]
Endfor
Display “The total is”, total
For k← maxnum to 0 STEP -1 Do
Display nums[k]
Endfor
For k ← 9 to maxnum STEP 10 do
Total ← total - nums[k]
Display “Enter a new value”
Read nums[k]
Total ← total + nums[k]
Endfor
Display “ The new total is”, total
Avg ← total / amtnum
For k← 0 to maxnum Do
If nums[k] > avg then
sum ← sum + 1
Endif
Endfor
Display “ The number of elements greater than average is ”, sum

STOP

You might also like