echo "Print no 1 to 20 in reverse"
no=20
while [ $no -ge 1 ]
do
echo $no
temp=` expr $no % 2 `
if [ $temp -eq 1 ]
then
c=` expr $c + $no `
fi
no=` expr $no - 1 `
done
echo "Sum of odd number is $c"
echo "Print no 1 to 20 in reverse"
no=20
while [ $no -ge 1 ]
do
echo $no
temp=` expr $no % 2 `
if [ $temp -eq 1 ]
then
c=` expr $c + $no `
fi
no=` expr $no - 1 `
done
echo "Sum of odd number is $c"
Leave a Reply