Code In Tech - The Ultimate World of Computer Technology

Saturday 12 May 2012

Shell script to find a max no out of three nos using else if & and operator.

SOURCE CODE:

echo “Enter the three nos.”
read a
read b
read c
if [ $a –gt $b –a $a –gt $c ]
then
     echo $a “is maximum no.”
elif [ $b –gt $a –a $b –gt -$c ]
then
     echo $b “maximum no.”
else
     echo $c “is maximum no.”

fi

OUTPUT

Enter the three nos.
4
3
2
4 is maximum no. 

No comments :

Post a Comment