WAP Find The sum Of The Digits Of The Number Entered At Command Line Gain Infiniti

WAP Find The sum Of The Digits Of The Number Entered At Command Line


for digit in "$@"
do
    sum=`expr $sum + $digit`
done

echo "The Sum of $* is $sum";


OUTPUT:-

#!/bin/bash
#root@slack-linunx:~/scripts# ./sumOfCmdDigits.sh 1 2 3 4 5
#The Sum of 1 2 3 4 5 is 15
#root@slack-linunx:~/scripts#
sum=0;

0 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 

Design By Manish and Ranjan