Write A Shell Script To Find Sum of Digits of A Number: "Input No: "
Write A Shell Script To Find Sum of Digits of A Number: "Input No: "
echo -n "Input no : " read no length=`expr length $no` while [ $length -ne 0 ] do b=`expr substr $no $length 1` ans=`expr $ans + $b` length=`expr $length - 1` done echo "Sum of Digit is : $ans"
1)sum=`expr $n1 + $n2` echo "Sum ="$sum;; 2)sum=`expr $n1 - $n2` echo "Sub = "$sum;; 3)sum=`expr $n1 \* $n2` echo "Mul = "$sum;; 4)sum=`expr $n1 / $n2` echo "Div = "$sum;; *)echo "Invalid choice";; esac echo "Do u want to continue ?" read i if [ $i != "y" ] then exit fi done
fi i=`expr $i + 1` done if [ $f -eq 1 ] then echo "The number is composite" else echo "The number is Prime" fi