168k views
1 vote
Write an algorithm for a program that reads in threenon-negative integer numbers and reports the maximum number,minimum number and average number. Write it in simple English, noneed of any programming language syntax.

1 Answer

5 votes

Answer:

Algorithm for finding maximum

Let the 3 numbers be x,y and z.

  1. First find maximum between x and y using if statement.
  2. if x is greater than y then compare x with z.If x is greater than z then x is maximum.Else z is maximum.
  3. if x is smaller than y compare y with z.If y is greater than z then y is maximum else z is maximum.

Algorithm for finding minimum

  1. First compare x with y.
  2. If x is larger than y then compare y with z.If z is smaller then minimum is z else it is y.
  3. If x is smaller then compare x with z.If z is smaller then z is minimum else it is x.

Algorithm for finding the average

  1. Initialize a double variable to store the result and an integer to store the sum.
  2. Assign the value sum/3 to the result and it is our average.

User Mcsim
by
5.7k points