Thursday, June 14, 2018

SHELL SCRIPT TO FIND THE LARGEST AMONG THREE NUMBERS.

SOURCE CODE

echo "Enter three numbers"
read x
read y
read z
if [ $x -gt $y ]
then
if [ $x -gt $z ]
then
echo "$x is the largest number"
else
echo "$z is the largest number"
fi
else
if [ $y -gt $z ]
then
echo "$y is the largest number"
else
echo "$z is the largest number"
fi
fi




Output ->   Enter three numbers
                     1
                     6
                     4
                     6 is the largest number

No comments:

Post a Comment