How do you write a pseudocode that accepts five numbers and displays the sum and average of the numbers?
To write pseudocode that accepts five numbers and displays their sum and average, you can follow these steps:
Initialize a variable sum to 0.
Loop five times to accept input for each number, adding each to sum.
After the loop, calculate the average by dividing sum by 5.
Display both the sum and the average.
Here’s a simple representation:
BEGIN
sum = 0
FOR i FROM 1 TO 5 DO
INPUT number
sum = sum + number
END FOR
average = sum / 5
OUTPUT "Sum: ", sum
OUTPUT "Average: ", average
END