Shell Script to find greatest of three. Script must consider the case where two numbers are equal.

 Shell Script:

ch=1
while [ $ch -eq 1 ]
do
echo "Enter First number: "
read a
echo "Enter Second number: "
read b
echo "Enter third number: "
read c
if [ $a -eq $b -a $b -eq $c -o $a -eq $b -o $b -eq $c -o $c -eq $a ];
then
echo "please enter 3 different values"
ch=1
elif [ $a -gt $b -a $a -gt $c ];
then
echo "$a is greatest number"
ch=0
elif [ $b -gt $a -a $b -gt $c ];
then
echo "$b is greatest number"
ch=0
else
echo "$c is greatest number"
ch=0
fi
done


Output:


All three values are Different Two values are same





Post a Comment

Previous Post Next Post
Best Programming Books

Facebook

AJ Facebook
Checkout Our Facebook Page
AJ Blogs
Checkout Our Instagram Page