THE SUM OF n DIFFERENT NUMBERS
echo"Enter the number of elements:"
read n
s=0
for((i=1;i<=n;i++))
do
echo"Enter the number: "
read no
s=expr $s+$no
done
echo"This sum is :$s"
REVERSE OF A GIVEN NUMBER
if [ $# -eq 1 ]
then
if [ $1 -gt 0 ]
then
num=$1
sumi=0
while [ $num -ne 0 ]
do
lnum=expr $num % 10
sumi=expr $num * 10 + $lnum
num=expr $num / 10
done
echo"Reverse of digits is $sumi of $1 "else
echo"Number is less than 0"
fi
else
echo"Insert only one parameter "
fi
0 comments:
Post a Comment