Friday, 12 December 2014

Shell Script to check for Positive, negative and zero numbers

Write a Shell Script to check whether the entered number is positive, negative or zero.
Solution:
echo " Enter a number"
read n
if test $n -eq 0
then
echo "The entered number is zero"
elif test $n -lt 0
then echo "The number is negative"
else
echo " The number is positive"
fi   

Execution:

No comments:

Post a Comment