A SHELL SCRIPT PROGRAM ON SORTING OF THREE NUMBERS - Code

Latest

programs

Wednesday, October 12, 2011

A SHELL SCRIPT PROGRAM ON SORTING OF THREE NUMBERS


 A SHELL SCRIPT PROGRAM ON SORTING OF THREE NUMBERS

echo "..A SHELL SCRIPT PROGRAM ON SORTING OF 3 NUMBERS..."
echo "Enter Three Numbers :"
read x
read y
read z
if [ $x -lt $y -a $x -lt $z ]
then
if [ $y -lt $z ]
     then
          echo $x $y $z
     else
          echo $x $z $y
     fi
elif [ $y -lt $z ]
then
if [ $x -lt $z ]
     then
          echo $y $x $z
     else
          echo $y $z $x
     fi
else
    if [ $x -lt $y ]
    then
          echo $z $x $y
    else
          echo $z $y $x
   fi
fi

[root@localhost root]# sh sort3.sh
.....A SHELL SCRIPT PROGRAM ON SORTING OF 3 NUMBERS.....

Enter Three Numbers :
11
44
22
11 22 44

[root@localhost root]# sh sort3.sh
.....A SHELL SCRIPT PROGRAM ON SORTING OF 3 NUMBERS.....

Enter Three Numbers :
14
81
25
14 25 81

No comments:

Post a Comment