English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Write an algorithm for a program that reads in three non-negative integer numbers and reports the maximum number, minimum number and average number. Write it in simple English (step by step), no need of any programming language syntax.

2006-11-13 14:12:47 · 4 answers · asked by KhaWaja 1 in Science & Mathematics Mathematics

4 answers

Input X
Input Y
Input Z
If x>=y and x >=z then L = x
If Y>=X and Y>=Z then L = Y
If Z>=X and Z>= Y then L = Z
Display "Largest is " L

Same 3 but use <=, store in S, display Smallest is S

A = (x+Y+Z)/3

Display "AVERAGE IS" A

2006-11-13 14:21:38 · answer #1 · answered by hayharbr 7 · 0 0

You are basically being asked what thought process you go through to determine these things. Write out how you would compare the numbers and decide which was the largest and smallest. Finding the average is pretty straight forward.

2006-11-13 14:17:36 · answer #2 · answered by Anonymous · 0 0

OK, so what would you do if you were the computer?

Read in the first number -- nothing to do
Read in the second number -- do some comparison?
etc..

2006-11-13 14:53:22 · answer #3 · answered by arbiter007 6 · 0 0

read firstNumber

set minNumber = firstNumber
set maxNumber = firstNumber
set total = firstNumber

loop twice
read nextNumber
if nextNumber < minNumber then minNumber = nextNumber
if nextNumber > maxNumber then maxNumber = nextNumber
total = total + nextNumber
end loop

Minimum is minNumber
Maximum is maxNumber
Average is total/3

2006-11-13 15:27:46 · answer #4 · answered by SpaceCtrl 2 · 0 0

fedest.com, questions and answers