Algorithm:
1. Prompt the user to input the first number.
2. Store the first number in a variable.
3. Prompt the user to input the second number.
4. Store the second number in a variable.
5. Prompt the user to input the third number.
6. Store the third number in a variable.
7. Add the three numbers together and store the sum in a variable.
8. Calculate the average of the three numbers by dividing the sum by 3 and store the result in a variable.
9. Determine the highest number by comparing each number to the others, and storing the largest value in a variable.
10. Determine the smallest number by comparing each number to the others, and storing the smallest value in a variable.
11. Output the sum, average, highest number, and smallest number.
Pseudocode:
1. Prompt user to input first number.
2. Store first number as variable "num1".
3. Prompt user to input second number.
4. Store second number as variable "num2".
5. Prompt user to input third number.
6. Store third number as variable "num3".
7. Set variable "sum" to num1 + num2 + num3.
8. Set variable "avg" to sum / 3.
9. Set variable "max" to the maximum value of num1, num2 and num3.
10. Set variable "min" to the minimum value of num1, num2 and num3.
11. Output sum, avg, max and min.
Flowchart:
START
|
v
ENTER num1
|
v
ENTER num2
|
v
ENTER num3
|
v
sum = num1 + num2 + num3
|
v
avg = sum / 3
|
v
IF num1 > num2 AND num1 > num3 THEN
max = num1
ELSE IF num2 > num1 AND num2 > num3 THEN
max = num2
ELSE
max = num3
END IF
|
v
IF num1 < num2 AND num1 < num3 THEN
min = num1
ELSE IF num2 < num1 AND num2 < num3 THEN
min = num2
ELSE
min = num3
END IF
|
v
OUTPUT sum, avg, max, min
|
END
how to write algorithm and pseudocode and how to draw flowchart to find the average,
max, min, and sum of three numbers given by the user
1 answer