Subscribe to Get Free Material Updates!
Visit my new blog WebData Scraping - Web Scraping Service provider company in India.

Accept number and check the number is even or odd finds the length of the number sum of the digits in the number


clear
echo "Enter number:"
read no;
count=0
total=0
while [ $no -ne 0 ]
do
 a=`expr $no % 10`
 no=`expr $no / 10`
 total=`expr $total + $a`
 count=`expr $count + 1`
done
if [ `expr $no % 2` -eq 0  ]; then
 echo "NUMBER IS EVEN"
else
 echo "NUMBER IS ODD"
fi
echo "SUM OF ALL DIGITS:$total"
echo "TOTAL NUMBER OF DIGIT:$count" 

Output:

0 comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...

 
Design by Wordpress Theme | Bloggerized by Free Blogger Templates | coupon codes