4th linux
Wed Nov 29 2023 07:47:59 GMT+0000 (Coordinated Universal Time)
Saved by
@viinod07
Write a shell script that accepts two integers as its arguments and computers the value of
first number raised to the power of the second number.
Script:
if [ $# -ne 2] then
echo “check the number of arguments”
fi
count=1
result=1
if [ $2 –ge 0 ] then
while [ $count –le $2 ] do
result=`expr $result \* $1`
count=`expr $count + 1`
done
echo “The Result is : $result”
fi
Output:
sh power.sh 5 2
The Result is: 25
content_copyCOPY
Comments