Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- sum=0
- echo -n "Sum of 1.Series 2.Digits: "
- read n
- case $n in
- 1):
- ip=1
- echo "Enter numbers to add. Press 0 to end."
- while [ $ip -ne 0 ]
- do
- read ip
- let sum+=ip
- done
- ;;
- 2):
- echo -n "Enter a number: "
- read ip
- while [ $ip -ne 0 ]
- do
- let r=ip%10
- let sum+=r
- let ip=ip/10
- done
- ;;
- *):
- echo "Invalid choice"
- exit 1
- ;;
- esac
- echo "The sum is $sum"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement