Share
Explore BrainMass

Pseudo-code and Program to Calculate Average

Declare Num1, Num2, and Num3 as integers
Declare Average as real
Write "Welcome to the program. Enter 3 positive numbers",
INPUT Num1, Num2, Num3
Average = (Num1 + Num2 +Num3) / 3
Write "The average of three numbers entered is", Average
Stop

1. List all variable name(s) used in this program
2. List each prompt that is used in this program.
3. Show what the PC monitor will show when the program is executed with the following values used: 27, 12, and 15.
4. Write a new program in pseudo-code, it should input-and calculate the average of 5 numbers entered.

Solution This solution is FREE courtesy of BrainMass!

1. Variables are placeholders for your data. You have explicitly declared them in your program.
They are: Num1, Num2, Num3, Average

2. Prompt is made for user input. There seems to be just one.
INPUT Num1, Num2, Num3

3. The PC monitor will show the Input/output (I/O) of the program. They are the write and INPUT statements in your program

output>Welcome to the program. Enter 3 positive numbers
input>27 12 15
output>The average of three numbers entered is 18

4. New pseudo-code for average of 5 numbers

It should be exactly the same except using 5 variables instead of 3 and obviously dividing by 5 instead of 3 when calculating the average of 5 numbers.

Declare Num1, Num2, Num3, Num4, and Num5 as integers
Declare Average as real
Write "Welcome to the program. Enter 5 positive numbers",
INPUT Num1, Num2, Num3
Average = (Num1 + Num2 +Num3 + Num4 +Num5) / 5
Write "The average of Five numbers entered is", Average
Stop