-2

By far, I can only get the numbers in average, but the largest number.

#! /bin/sh
# Get input numbers from user
 echo Please enter three numbers
 read a b c
# Calculate average of input numbers
avg=`expr \( $a + $b + $c \) / 3`
# Display the result
echo The average of the two input numbers is $avg
exit
chepner
  • 497,756
  • 71
  • 530
  • 681
  • @123: OP doesn't read the i/p's to an array, so might not apply for an exact duplicate, ain't it? – Inian Aug 23 '16 at 13:08
  • 2
    @Inian Same logic, and it is obviously better to use an array for this, so it may as well be a dup. – 123 Aug 23 '16 at 13:10

1 Answers1

0

try this;

#! /bin/sh
# Get input numbers from user
 echo Please enter three numbers
 read a b c
# Calculate average of input numbers
avg=`expr \( $a + $b + $c \) / 3`


for i in $a $b $c ; do
    ((i > max)) && max=$i
done

echo The maximum number of the three input numbers is $max
# Display the result
echo The average of the three input numbers is $avg
exit
Mustafa DOGRU
  • 3,994
  • 1
  • 16
  • 24