Code In Tech - The Ultimate World of Computer Technology

Saturday 12 May 2012

Shell script to find the max. no out of given five nos.

SOURCE CODE:

echo “Enter five nos.”
i=0
b=0
t=0
while [ $i –lt 5 ]
do
     read a
     b= $t
     if teat $b –lt $a
     then
           t= $a
     else
           t=$b
     fi
     i=`expr $i + 1`
done
echo “Max:“ $t

OUTPUT:

Enter five nos. 
1
5
7
3
8
Max:8 

No comments :

Post a Comment