Friday 27 March 2020

Shell program to find the sum of the square of the digits of a number

PROGRAM
echo "Enter the Number :"
read number
n=$number
sum=0
while test $number -gt 0
do
    rem=` expr $number % 10 `
    sum=` expr $sum + $rem \* $rem `
    number=` expr $number / 10 `
done
echo "The Sum Of Square Of Digits in the Given Number $n is $sum"



OUTPUT
Enter the Number :
12
The Sum Of Square Of Digits in the
Given Number 12 is 5