Translate

Labels

Tuesday, 15 January 2013

SHELL PROGRAMS

LARGEST AMONG 'n' NUMBERS

echo"Enter the number of elements:"
read n
l=0
for((i=1;i<=n;i++))
do 
echo"Enter the number:"
read no
if[$no -gt$l]
then l=$no
fi
done
echo"The largest number is:$l"

THE LARGEST DIGIT OF A NUMBER

echo"Enter a number:"
read n
s=0
while [ $n -gt 0 ]
do 
r='expr $n%10'
if[$r -gt $s]
then 
s=$r
fi
n='expr $n/10'
done 
echo"The largest digit is:$s"

No comments: