Find Sum Of Five Digit Number In the basic shell programming in Linux UNIX script programming


These program find out the sum of the five digit number using while loop, it uses the modulo division operator, and division operator to perform these program.
Source code bash shell Programming Algorithm
echo "Enter the number"
read num
while test $num -gt 0
digit=`expr $num % 10`
num=`expr $num / 10`
sum=`expr $sum + $digit`
echo "sum of the digits= $sum"

OUPUT CS1252 Operating Systems lap
[redhat33@localhost jana]$ sh
Enter the number
sum of the digits= 15

No comments:
Write comments