Accept number and check the number is even or odd, find the length of the number, sum of the digits in the number.

echo -e “Enter the number:\c”

read n

if [ expr $n % 2 -eq 0 ]

then

echo “$n is Even”

else

echo “$n is Odd”

fi

l=echo $n|wc -c

temp=$n

echo “Length of the number is::expr $l - 1

 

while [ $n -gt 0 ]

do

t=expr $n % 10

rev=expr $rev + $t

n=expr $n / 10

done

echo “Sum of the  digits $temp is::$rev”

 

OUTPUT::

 

Enter the number:123

123 is Odd

Length of the number is::3

Sum of the  digits 123 is::6

 

 

Share

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.